Link to home
Start Free TrialLog in
Avatar of rmtogether
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
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

This is how you get current working directory:
http://www.roseindia.net/java/example/java/io/GetCurrentDir.shtml
Avatar of rmtogether
rmtogether

ASKER

it seems to me the files also include hidden file of the directory. Can I exclude those hidden files?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

methid File.isHidden() should return boolena which you can check
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you so much