Tuesday, April 19, 2011

How to get the parent directory of a file in java?

Use file.getParent() method for this:

File file = new File("C:/File/demo.txt");
String strParentDirectory = file.getParent();

No comments:

Post a Comment

Chitika