|
Properties p = new Properties();
p.load(new FileInputStream("D:\\Myworkspace\\Test\\Demo\\ApplicationResources_ja.properties"));
BufferedReader reader = new BufferedReader(new FileReader("D:\\Myworkspace\\Test\\Demo\\ApplicationResources_ja.properties"));
String str = null;
while((str=reader.readLine())!=null){
if(str.equals("")){
System.out.println("此行为空");
}else{
if(str.indexOf("=")==-1){
System.out.println("这一行没有键值映射===>>>>>>"+str);
}else{
String [] arr = str.split("=");
// System.out.println(arr[0]);
// System.out.println(arr[1]);
// 这两种输出转换方式都行不通???????为什么
// String temp = new String(arr[1].trim().getBytes(),"GBK");
// System.out.println(arr[0]+"="+temp);
// arr[1] = new String(arr[1].trim().getBytes(),"GBK");
// System.out.println(arr[1]);
//
// 下面的两种输出方式 都可以 ,都是使用的 Properties 对象加载文件
// String temp = p.getProperty(arr[0]);
// temp = new String(temp.trim().getBytes(),"GBK");
// System.out.println(arr[0]+"==="+temp);
arr[1] = p.getProperty(arr[0]);
arr[1] = new String(arr[1].trim().getBytes(),"GBK");
System.out.println(arr[0]+"==="+arr[1]);
}
}
} |
|