I am writing a comparator class that compares the file size of one file to another file in the same directory. I am having trouble finding the right documentation to get the file size of a file.
Right now I am looking at the documentation here for getObjectSize:
Here is my code, however it does not seem to be working.
public class FileComparator implements Comparator {
private static Instrumentation instrumentation;
@Override
public int compare(Object o1, Object o2) {
throw new UnsupportedOperationException("Not supported yet.");
}
static long getObjectSize(Object objectToSize) {
return instrumentation.getObjectSize(objectToSize);
}
}
public class Comparison {
public static void main(String[] args) {
File file = new File("src/Dummy1.pdf");
System.out.println(FileComparator.getObjectSize(file));
}
}
I get a NullPointerException thrown.