我想将文件 results.txt 写入我机器上的特定目录(准确地说是 Z:\results)。如何将目录指定给 BufferedWriter/FileWriter?
目前,它成功地将文件写入我的源代码所在的目录。谢谢
public void writefile(){
try{
Writer output = null;
File file = new File("results.txt");
output = new BufferedWriter(new FileWriter(file));
for(int i=0; i<100; i++){
//CODE TO FETCH RESULTS AND WRITE FILE
}
output.close();
System.out.println("File has been written");
}catch(Exception e){
System.out.println("Could not create file");
}
}