File f
=
new
File(
"
c:\\my.properties
"
);
Properties prop = new Properties();
if (f.exists()) {
try {
InputStream in = new FileInputStream(f);
prop.load(in);
in.close();
System.out.println(prop.get( " requestTime " )); // 讀properties文件
OutputStream out = new FileOutputStream(f);
prop.setProperty( " derek " , " dada " ); // 設(shè)置屬性
prop.store(out, " THE LOCKED TIME SET " ); // 寫properties文件
} catch (FileNotFoundException ex) {ex.printStackTrace();
} catch (IOException ex) {ex.printStackTrace();}
} else System.out.println( " 文件不存在 " );
Properties prop = new Properties();
if (f.exists()) {
try {
InputStream in = new FileInputStream(f);
prop.load(in);
in.close();
System.out.println(prop.get( " requestTime " )); // 讀properties文件
OutputStream out = new FileOutputStream(f);
prop.setProperty( " derek " , " dada " ); // 設(shè)置屬性
prop.store(out, " THE LOCKED TIME SET " ); // 寫properties文件
} catch (FileNotFoundException ex) {ex.printStackTrace();
} catch (IOException ex) {ex.printStackTrace();}
} else System.out.println( " 文件不存在 " );