因此,我正在编写 FTP 服务器-客户端,但代码无法读取任何文件。我是说。我在下载中有一个文件。比方说/Downloads/supplement2.pdf 但我得到一个 FileNotFoundException。即使文件在那里并且我可以看到它。我什至制作了一个测试文件夹并将其权限设置为 777。仍然没有。
有没有办法设置 netbeans 作为 super 用户或其他什么?我是说。我只想复制和粘贴一些东西,但不能。这是复制和粘贴代码。如果您发现任何问题,请分享。
public static void copyFile(File in, File out)
throws IOException
{
FileChannel inChannel = new
FileInputStream(in).getChannel();
FileChannel outChannel = new
FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(),
outChannel);
}
catch (IOException e) {
throw e;
}
finally {
if (inChannel != null) inChannel.close();
if (outChannel != null) outChannel.close();
}
}
谢谢
最佳答案
您指定的文件路径是否正确?
您可以尝试指定完整路径或将文件放在与代码相同的目录中。
关于java - 程序看不到文件,但它存在。 FileNotFoundException异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2124984/