Results 1 to 4 of 4
- 02-08-2008, 07:13 PM #1
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 609
- Rep Power
- 6
Is there a way to read a file directory
Best java friends
Is there a way to read a file directory in a specific folder inside the work directory form a applet . The following code does not work in an applet:
directory = new File(dirname);
if (directory.isDirectory() == false) {
if (directory.exists() == false)
…………
files = directory.list(); // stores the list of file names
willemjav
- 04-17-2008, 03:52 PM #2
For security reasons, you can't actually..... ( im not sure )
try to search it on the web....
specially the article about Advantage/disadvantage of Applets....
sukatoa.
- 04-17-2008, 04:54 PM #3
This code will list all the files in a given directory. In this case its '.' which is the current working directory:
Java Code:String path = "."; File folder = new File(path); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { files = listOfFiles[i].getName(); System.out.println(files); } }Did this post help you? Please
me! :cool:
- 09-05-2011, 01:01 AM #4
Member
- Join Date
- Sep 2011
- Posts
- 1
- Rep Power
- 0
Re: Is there a way to read a file directory
I cleaned up your code a little.
Java Code:String path = "C:/"; File folder = new File(path); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { String files = listOfFiles[i].getName(); System.out.println(files); } }
Similar Threads
-
How to get Current Directory through File
By Java Tip in forum java.ioReplies: 0Last Post: 04-05-2008, 10:14 AM -
How to read a text file from a Java Archive File
By Java Tip in forum Java TipReplies: 0Last Post: 02-08-2008, 09:13 AM -
signaling file(s) have reached in directory
By ashu261 in forum Advanced JavaReplies: 0Last Post: 02-04-2008, 07:45 AM -
Read file
By tajinvillage in forum Threads and SynchronizationReplies: 0Last Post: 01-29-2008, 09:10 AM -
How to Move a File to Another Directory
By Ada in forum New To JavaReplies: 1Last Post: 05-26-2007, 01:17 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks