Home Answers Viewqa Java-Beginners JAVA Compile Question ?

 
 


bob
JAVA Compile Question ?
1 Answer(s)      10 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");
      }
   }
}
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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.