![]() |
| ||
| Recursive File List - Help me problem solve please Hello My recursive file scan is not doing what I want it to do. 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. import java.io.*; At the moment I just get a null pointer exception... I dont understand where Ive gone wrong in the code: if its a file --> return the file name --> if its a directory --> list the files in the directory Help please! |
| ||
| Re: Recursive File List - Help me problem solve please Hello, Code is working perfectly! No NPException. Using Eclipse SDK Version: 3.4.0. Best of luck! |
| ||
| Re: Recursive File List - Help me problem solve please File has a method that returns all the system "roots". See the API docs for File. |
| ||
| Re: Recursive File List - Help me problem solve please really thats interesting punnetkay i wonder why but it needs to work for me! 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. 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? |
| |||
| Re: Recursive File List - Help me problem solve please Quote:
Quote:
Quote:
Why does no one ever listen to what I say? |
| ||
| Re: Recursive File List - Help me problem solve please Hello again, And again its working fine for me. public static void main(String[] args) {Regards, |
| ||
| Re: Recursive File List - Help me problem solve please 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. |
| ||
| Re: Recursive File List - Help me problem solve please can I add a equals() statement in the code above and from that print to the terminal window files that occur on more than one instance on the recursive scan? |
| ||
| Re: Recursive File List - Help me problem solve please 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. |
| ||
| Re: Recursive File List - Help me problem solve please lol i started that thread but ignore that one for now lol anyways thanks masijade for your reply i tried something new modified code below public static void search(File f) {well to the code ive added the following line: if (f.length() <= 1) return; but i dont think it has had any change in the list of results brought to the terminal window can some one with more java knowledge tell me why please? any help or correction welcomed! |
| All times are GMT -4. The time now is 4:31 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC