sarahchi
asked on
how to get directory and file name easily?
Hi,
I have a String which includes both directory name and file name, I could not find a simple function to break the string into direcoty name and file name. I tried
File file = new File(Name);// name includes both path and file name
then I used different get function from File class, but always got the whole string for the directory name, please help!
I have a String which includes both directory name and file name, I could not find a simple function to break the string into direcoty name and file name. I tried
File file = new File(Name);// name includes both path and file name
then I used different get function from File class, but always got the whole string for the directory name, please help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
both returns f to me:
f.getName();
f.getPath();
I don't know what they really do?
f.getName();
f.getPath();
I don't know what they really do?
String s = "/some/directory/file.name ";
File f = new File(string);
then use the methods in the File class to access what you need
File f = new File(string);
then use the methods in the File class to access what you need
ASKER
thanks, but what is " abstract pathname"?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
f.getName();
f.getPath();