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>
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5383393.html,如需转载请自行联系原作者