如果我运行这段代码什么也没有发生,甚至没有发现异常。字符串不会发生在test.txt文件中。 test.txt文件的路径是〜/ home/joci/Joci。我东错了什么?Linux上的FileWrite路径
public static void main(String[] args) {
try{
String text = "this is just a test ";
FileWriter fw = new FileWriter("/home/joci/Joci test.txt");
fw.write(text);
fw.close();
}catch(IOException e){
System.out.println("Something went wrong ");
}
你忘了缩进你的代码。这不是你问题的根源,但是你做错了。 – khelwood
路径中的空间或检查错误的位置:'〜/ home/joci/Joci'你确定吗?你家里放了个家庭文件夹吗? –
这是文件名吗? Joci test.txt – XtremeBaumer