我正在尝试将某些内容写入文件,如下所示:
FileWriter fw = new FileWriter("somefile.txt", true);
当由单个进程启动时,它可以正常工作。像这样:
java -jar XXXXXXX.jar
但是当被另一个进程调用时,会抛出一个IOException。例子:
java.io.FileNotFoundException: 'somefile.txt' (No such file or directory)
at java.io.FileOutputStream.openAppend(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:192)
at java.io.FileOutputStream.<init>(FileOutputStream.java:116)
at java.io.FileWriter.<init>(FileWriter.java:61)