import java.util.Properties;
import java.io.*;
public class ReadValues{
private static final String PROP_FILE="myConfig.properties";
public static void readPropertiesFile(){
try{
InputStream is = ReadValues.class.getResourceAsStream(PROP_FILE);
Properties prop = new Properties();
prop.load(is);
String directory = prop.getProperty("Directory");
String numberOfFiles = prop.getProperty("NumberOfFiles");
String fileExtension = prop.getProperty("Extension");
is.close();
/* code to use values read from the file*/
}catch(Exception e){
System.out.println("Failed to read from " + PROP_FILE + " file.");
}
}
}
Let me know how to retrieve the properties file from local drive in java.I do not want to hard code the drive name. for eg c:\app.properties i want this as output