Monday, 18 April 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