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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
:-)
f.getName();
f.getPath();