jdk1.6
package read;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;
public class FileRead {
public static void main(String[] args) {
FileRead re=new FileRead();
String x=re.gete();
System.out.println(x);
}
public String gete(){
Properties props = new Properties();
System.out.println(new File("").getAbsolutePath());
try {
props.load(new InputStreamReader(new FileInputStream(new File("").getAbsolutePath()+"/src/config/read.properties"), "UTF-8"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String isuse = props.getProperty("ISUSE");
return isuse;
}
}
jdk1.7及以上
import java.io.InputStream;
import java.util.Properties;
Properties pro = new Properties();
try(InputStream is = getClass().getResourceAsStream(
"/config/Multi-Language-Configuration.properties")) {
pro.load(is);
} catch (Exception e) {
}
String isuse = pro.getProperty("ISUSE");