我试图在资源文件夹中写一个.txt文件,但它没有写任何东西.通过执行以下操作,我能够读取相同的.txt文件:
Scanner scanner = null;
InputStream IS = MyClass.class.getResourceAsStream("/File/My FileH");
scanner = new Scanner(IS);
Run Code Online (Sandbox Code Playgroud)
但是当谈到写作时,我尝试过:
PrintWriter writer = new PrintWriter(
new File(this.getClass().getResource("/File/My FileH").getFile()));
writer.println("hello");
writer.close();
Run Code Online (Sandbox Code Playgroud)
有关如何在该文件夹中写入的任何建议?
java ×1