java.io.FileNotFoundException:“C:/Users/Joe/Desktop/file.txt”(文件名,目录名或卷标语法不正确)

我有这个代码:

BufferedReader in = new BufferedReader
(new InputStreamReader(System.in));
System.out.print("Public Key to encrypt with: ");
String publicKeyFilename = in.readLine();
FileInputStream fis = new FileInputStream(publicKeyFilename);

当我输入文件“C:/Users/Joe/Desktop/file.txt”的目的地时,结果是这个错误:

java.io.FileNotFoundException: “C:/Users/Joe/Desktop/file.txt” (The
filename, directory name, or volume label syntax is incorrect)

但文件存在,所以我该怎么办?

感谢你..

最佳答案

when i enter the destination of the file
“C:/Users/Joe/Desktop/file.txt”

文件名应该没有引号(“”)

点赞