我在写一个txt文件时遇到了麻烦.我得到一个FileNotFound异常,但我不知道为什么因为该文件肯定是存在的.这是代码.
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.File;
public class Save
{
public static void main(String[] args)
{
File file = new File("C:/Users/Daniel/Desktop/Programs/Save Data Test/save.txt");
PrintWriter pw = new PrintWriter(file);
pw.println("Hello World");
pw.close();
}
}
Run Code Online (Sandbox Code Playgroud)