Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners JAVA Compile Question ?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


bob
JAVA Compile Question ?
1 Answer(s)      2 years and 2 months ago
Posted in : Java Beginners


I'm unable to compile this file and not sure why? Can someone please help?

import java.nio.file.*;
import java.nio.file.attribute.*;
import java.nio.file.attribute.Attributes;
import java.io.IOException;
public class FileStatistics2
{
   public static void main(String[] args)
   {
      Path textFile =
         Paths.get("C:\\quote.txt");
      Path wordFile =
         Paths.get("C:\\quote.docx");
      try
      {
         BasicFileAttributes attrText =
            Attributes.readBasicFileAttributes(textFile);
         BasicFileAttributes attrWord =
            Attributes.readBasicFileAttributes(wordFile);
         long textSize = attrText.size();
         long wordSize = attrWord.size();
         double ratio = textSize * 100.0 / wordSize;
         System.out.println(textFile.toString() + " is " +
            textSize + " bytes long");
         System.out.println(wordFile.toString() + " is " +
            wordSize + " bytes long");
         System.out.println("The text file is " +
            ratio + "% of the size of the word file");       
      }
      catch(IOException e)
      {
          System.out.println("IO Exception");
      }
   }
}

Advertisement
View Answers

July 3, 2012 at 10:24 AM


The classes that you are using in your code needs jdk 7. So, you have to install jdk 7 in your system to import the required classes.



Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com