Most of projects we don't use absolute path instead we use relative path thats best practice. in this discussion we will see how to get string name of current working folder so after that we can get relative path corresponding to that base location . so simple just few lines :)
public static String getCurrentDirectory(){
String cwd = null;
try{
cwd = new java.io.File( "." ).getCanonicalPath();
} catch (java.io.IOException e)
{
log.error("Error in getting present working Directory");
}
return cwd;
}
No comments:
Post a Comment