File has a method that returns all the system "roots". See the API docs for File.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
post above: thanks for that, but I dont want to list the roots I want to list the files and files in directories that are in all directories on a computer.
Then what was this?I want it to be able to go through all roots (drives)...
With no user intervention, so without including "C:\\" or "." as a string in the source, or without a TextIO.java class.
As that is the part I was responding to. You willneed to use that.
I think Ive got some stable code now. But I still want to know how to recursive scan the whole computer and not just a drive. At the moment I'm able to scan "C:\\" or "D:\\" and not both, does any one know how I can make that work?
See above. You can only "recursively" scan each drive/root one at a time. But you can loop over what the above mentioned method returns.Why does no one ever listen to what I say?
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
The NPE (as the OP already knows from his post on www.java-forums.com (or is it org?)) is because listFiles will return null on an empty directory so he needs to add an if statement to check for that.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
Detection of duplicate files isn't that simple; refer a similar thread . If that's not what you intend, a bit more explanation is needed.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
> but i dont think it has had any change in the list of results brought
> to the terminal window
And what were you expecting by checking if the file size is less than or equal to one byte?
Maybe posting/uploading a virtual directory structure along with the expected output might help others in collaborating for a better solution.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
I'm fairly sure you meant "files.length" and not "f.length()".
Edit: Not that that matters though. Once the loop is done, the method will return anyway.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
so just to add more detail because theyre may be confusion
Im basically trying to get files with equal file size first, then im trying to put those in an array, then the files in the array need to be compared possibily by length (bytes) (not file names but files contents), the comparison need to be made maybe by binary contents or by generating an MD checksum which ever ones easier.
Like it has already been mentioned by masijade, you have to make a stab at this and post again if you have any problems. Just putting in random conditional statements here and there won't cut in. Since you already seem to know the logic, you can at least try implementing it.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
> i just thought you guys would of liked a challenge lol
I have got enough challenges in my daily life, I guess I'll just pass. :-)
But don't give up hope, who knows, masijade might just end up dropping in a jar file here with a "meh" look on his face. ;-)
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
I don't even understand what you mean by that question. Your code is only processing the top level of each root entry and only then if it's a directory.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847