java - 程序看不到文件,但它存在。 FileNotFoundException异常

标签 java copy-paste filenotfoundexception

因此,我正在编写 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/

相关文章:

java - Apache Commons MultiMap 已弃用,我现在应该使用什么?

java - 小程序图像缓存

java - FileOutputStream.flush() 能否保证其他进程能够一致读取文件内容?

java - 不可变类型的 setter/getter

iphone - 剪切/复制/粘贴功能在我的 iOS 应用程序中停止工作

javascript - 如何在 HTML + Javascript 中发送数组编号

java.io.FileNotFoundException : File is not a normal file. 露天

vim - 从腻子中运行的vim复制内容

c# - 为什么我可以在 PowerShell 中获取 SPSite 但在 C# 中使用 FileNotFound 失败?

java - 如何使用 FileInputStream 加载配置 xml 文件,但出现 FileNotFoundException