即使在提及路径之后,我在提及路径时也会出现以下'\'
错误
File file = new File("E:\\RConnect4s\\RConnect4s\\ZoneEast\\Utilities\\NBR.txt");
我的完整代码
public class UnixInterface implements Serializable {
String content = "This is the content to write into file";
/*File file = new File("E:\\RConnect4s\\RConnect4s\\ZoneEast\\Utilities\\NBR.txt");*/
File file = new File("E:\\RConnect4s\\RConnect4s\\ZoneEast\\Utilities\\NBR.txt");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(content);
bw.close();
System.out.println("Done");
}