开发者

Progam can't see file but it exist. FileNotFoundException

So, I'm writing FTP server-client but the code can't read any file. I mean. I have a file at Downloads. Let's say /Downloads/supplement2.pdf but I get a FileNotFoundException. Even though the file is there and I can see it. I even made a test folder and set it's privilages to 777. Still, nothing.

Is there a way to set what netbeans does as superuser or something? I mean. I just want to copy and paste something but can't. Here's the copy and paste code. If you see anything wrong with it please share.

 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();
        }
    }开发者_C百科

Thanks


Are you specifying the right path to the file?

You can try specifying the full path or placing a file in the same directory as the code.


Try just creating a new file with an unusual name, writing something to it and then finding the file in your file system.


I pasted and called your code with

copyFile(new File("C:/TEMP/Folder1/test.txt"), 
         new File("C:/TEMP/Folder2/test.txt"));

while only file in folder 1 existed and - yes, it worked. A complete stack trace could be helpful. Is any folder or document in the source or target path a mount or a link?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜