rmtogether
asked on
Using Java to get file names and directory
Hi, experts
I would like use JAVA to
1. get the current directory. for example my current directory in my java code is in (c:\abc)
2. After that I want to get ONLY files without director in to File[] something like below
File folder = new File("c:/abc");
File[] listOfFiles = folder.listFiles();
could you please teach me how can I can the
(1) file name only. for example test.txt
(2) file name with full path. for example c:\abc\test.txt
I would like use JAVA to
1. get the current directory. for example my current directory in my java code is in (c:\abc)
2. After that I want to get ONLY files without director in to File[] something like below
File folder = new File("c:/abc");
File[] listOfFiles = folder.listFiles();
could you please teach me how can I can the
(1) file name only. for example test.txt
(2) file name with full path. for example c:\abc\test.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it seems to me the files also include hidden file of the directory. Can I exclude those hidden files?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
methid File.isHidden() should return boolena which you can check
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you so much
This is how you get current working directory:
http://www.roseindia.net/java/example/java/io/GetCurrentDir.shtml