₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,327,357 members, 8,430,636 topics. Date: Saturday, 20 June 2026 at 07:43 PM

Toggle theme

Urgent Help With Directories In Java. - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingUrgent Help With Directories In Java. (1093 Views)

1 Reply (Go Down)

Urgent Help With Directories In Java. by Nov1ce(op): 2:02pm On Jun 27, 2011
Hey,
am working of an app and part or the funtionality is that it should be able to list all files on your drive (I'll do the file filter myself).
amd I need help with that regard.
The main thing is that it should transverse directories and sub directories in that directory and so on until it gets to a point where there are not more sub directories. Am using Java. This is really urgent.
Re: Urgent Help With Directories In Java. by Fayimora(m): 2:19pm On Jun 27, 2011
Before i start explaining some long shit, do you have some code down already that doesn't work as it would be easier and faster to help in that case, else would just go on with the explanation
Re: Urgent Help With Directories In Java. by SayoMarvel(m): 5:25pm On Jun 27, 2011
@Fayimora Good one there.
@Poster What do you have on ground? That way, it will be easier to help. But then, there is a list() method buried somewhere in the I/O API, and there is another method to list the root drives on the file system. I won't spoon feed you so go and dig through the API documentation for the java.io package. The find feature in your browser will make it easier, trust me.
Re: Urgent Help With Directories In Java. by wassolldas: 5:41pm On Jun 27, 2011
API: http://www.oracle.com/technetwork/java/javase/documentation/api-jsp-136079.html

For java 6 at http://download.oracle.com/javase/6/docs/api/
java.io.File
- isDirectory method tells you if the path is a directory or not.
- isFile method tells you if the path is a file.

- list method - Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.
- listFiles - Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.


Refer to the API and write the code to do what you need.
Re: Urgent Help With Directories In Java. by Shimao(m): 6:51pm On Jun 27, 2011
You've been given all you need but just to add, you might need to add some recursive code and you might as well check up the Composite design pattern.
1 Reply

Problem With Bufferedinputstream Read Blocking Issue In JavaI Want To Develop A Software In Java To Calculate CGPAHow Do Io Create Ribbon Ui In Java234

School Management Online ApplicationBacklink MakerBest Websites To Learn Programming For Free