这是用于删除文件 f1 并将文件 f2 重命名为 f1 的代码。但它返回 false。
String strLine;
File f1 =new File("C:\\Equinox\\RootSipResource\\root\\root.properties");
File f2 =new File("C:\\Equinox\\RootSipResource\\root\\root1.properties");
FileInputStream fin = new FileInputStream(f1);
BufferedReader br = new BufferedReader(new InputStreamReader(fin,"UTF-8"));
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(f2), "UTF-8");
while ((strLine = br.readLine()) != null) {
strLine = strLine.replace("root.label.43.2=PBS Kids"," root.label.43.2=PBS Kids NEW");
out.write(strLine);
out.write("\n");
}
out.flush();
out.close();
br.close();
//fin.close();
boolean delete= f1.delete();
boolean rename=f2.renameTo(f1);
System.out.println("delete----"+delete+ "rename-----"+rename);