Package com.xy;
Import Java.io.File;
Import Java.io.FileInputStream;
Import java.io.FileNotFoundException;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import java.io.UnsupportedEncodingException;
Import java.util.Properties;
public class Test {
/**
* @param args
* @throws filenotfoundexception
* @throws unsupportedencodingexception
*/
public static void Main (string[] args) throws FileNotFoundException, Unsupportedencodingexception {
FileInputStream in =null;
inputstreamreader ir =null;
File File = new file (Thread.CurrentThread (). Getcontextclassloader (). GetResource ("Fileupload.properties"). GetPath ());//Get Path
Properties P = new properties ();
in = new FileInputStream (file);
ir = new InputStreamReader (in, "utf-8");
try {
p.load (IR);
String s = P.getproperty ("File.projectlogo");
System.out.println ("File.projectlogo path read as" +s);
} catch (IOException e) {
e.printstacktrace ();
}
}
}
The result of the final printing is: File.projectlogo path read as D:/upload
Where the file.projectlogo=d\:/upload configured in the Fileupload.properties file
Java Methods for reading resource files