Java读取properties文件
1、perm.properties文件的配置
iapp.perm.CAMERA=摄像头
iapp.perm.SMS=短信
2、读取properties配置文件的内容(通过java.lang.Class类的getResourceAsStream(String name) 方法来实现)
<span style="font-family:Microsoft YaHei;font-size:12px;">import java.io.InputStream; import java.io.InputStreamReader; import java.util.Properties; public class Test { public static void main(String[] args) throws Exception { Properties properties = new Properties(); InputStream in = Test.class.getClassLoader().getResourceAsStream("/perm.properties"); // properties.load(in); properties.load(new InputStreamReader(in, "UTF-8")); // 解决中文乱码问题 String camera = properties.get("iapp.perm.CAMERA").toString(); String sms = properties.get("iapp.perm.SMS").toString(); } }</span>