I am trying to write a method that finds the depth of a file system and another that finds the largest file. I have several folders which contain simple text files and are at various depths within the directories. I think there might be a problem with the file input, like it’s not taking anything in or something? Here is the stacktrace:
Exception in thread "main" java.lang.NullPointerException
at FileExploration.largestFile(FileExploration.java:68)
at FileExploration.main(FileExploration.java:14)
Here are the lines that are in this trace:
public static void main (String[] args) {
System.out.println(largestFile(new File(
"c:/home/skatty14/workspace/LargestFile"))); //Line 14
}
File[] files = h.listFiles();
for (File f: files) { //Line 68
File lf = largestFile(f);
Anyone know how to make it so this will work correctly? I suspect that the input file in line 14 is not being “taken in” properly or something? I have no idea WHY, however…any light that someone can shed on this issue would be much appreciated, thanks!
Edit: Oh, ok…I think I might have found the problem!? I am using Linux: Ubuntu- Lucid Lynx, which doesn’t even have a c:/ HD directory. Although, how do I access a filesystem from Java (in the Home directory in particular)?
Edit2: SOLVED: I just changed the directory to one of my external harddrives. Perhaps permissions were blocking access to the Home folder, I don’t know…I fixed it somehow anyways! 😉
Path to your home directory on ubuntu; /home/username/