View Single Post
  #1 (permalink)  
Old 12-12-2007, 12:41 AM
MattStone MattStone is offline
Member
 
Join Date: Dec 2007
Posts: 13
MattStone is on a distinguished road
can java.io.File create a list of all files and folders.
Hello,

My goal is to create a app that will take the folder passed to it and spit out a txt file with a list of all the files and folders with last modify date.
Example,
C:\<TAB>12/1/2007 1:00 PM
C:\config.sys<TAB>12/1/2007 1:00 PM
C:\Windows\<TAB>12/1/2007 1:00 PM
C:\windows\test.txt<TAB>12/1/2007 1:00 PM
C:\windows\Program Files\<TAB>12/1/2007 1:00 PM
C:\windows\Program Files\test.txt<TAB>12/1/2007 1:00 PM

I have played with several options from parsing a dos output, and java.io.File list /w for loop and if isDirectory. The dos output may work if I get the time and patience to tweak it and the java.io.File is a better possibility.

I would like to use java.io.File to do this the issue that I am running is it only takes the current directory and not next one. I could rap it in a method and call on every directory would this pause untill the new folder is complete? Does that make since, LoL?

Code:
public FolderList(String str) { File b = new File(str); String [] ch = b.list(); path = str; for (int i = 0; i < ch.length; i++){ File c = new File(path + ch[i]); if (c.isDirectory()){ System.out.println(path + ch[i] + "\\"); } else System.out.println(path + ch[i]); } }
Please tell me there is a easier way....
In VB6 I did something similar and used a FileBox thingy and displayed path and filename in txt box then sent to list box (list box has a max # of items, ugh!!! Java is better anyway .)

Now that I have effectivly wasted space, can you please help a little... you don't have to do the code, I would just like guidance and maybe simplistic example.

YOU ROCK...Thanks is advance, i'll shut up now.... this is so much fun, I'm going to learn more and more... thanks.
Reply With Quote
Sponsored Links