public class PropertiesTester {
public static void main (String[] args){
Properties p = new Properties();
BufferedReader in = null;
BufferedWriter out = null;
try{
in = new BufferedReader(new InputStreamReader(PropertiesTester.class.getResourceAsStream("test.properties")));
p.load(in);
p.setProperty("married", "未婚");
out = new BufferedWriter(new FileWriter("D:\\Workplace\\Java_pro\\c10\\src\\com\\easyjava\\minepro\\test.properties"));
p.store(out, null);
}catch (IOException e){
e.printStackTrace();
}finally {
if (in != null){
try{
in.close();
out.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
StringBuffer tempSb = new StringBuffer();
Process q = null;
try {
q = Runtime.getRuntime().exec(
"native2ascii -reverse D:\\Workplace\\Java_pro\\c10\\src\\com\\easyjava\\minepro\\test.properties");
} catch (IOException e) {
e.printStackTrace();
}
InputStreamReader child_in = new InputStreamReader(q.getInputStream());
int c;
try {
while ((c = child_in.read()) != -1) {
tempSb.append((char) c);
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(tempSb);
}
}
Properties类文件的的操作
最新推荐文章于 2022-03-21 10:17:07 发布