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");
}
}
}
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.