【发布时间】:2010-01-24 07:20:25
【问题描述】:
所以,我正在编写 FTP 服务器客户端,但代码无法读取任何文件。我是说。我在下载有一个文件。假设 /Downloads/supplement2.pdf 但我得到一个 FileNotFoundException。即使文件在那里,我可以看到它。我什至创建了一个测试文件夹并将其权限设置为 777。仍然没有。
有没有办法设置 netbeans 作为超级用户做什么?我是说。我只想复制和粘贴一些东西,但不能。这是复制和粘贴代码。如果您发现它有任何问题,请分享。
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();
}
}
谢谢
【问题讨论】:
-
你不是在 chroot 中,是吗?
-
出于兴趣,您是在编写这个作为编程练习吗? (...因为否则您可以使用许多 Java FTP 库实现)。
-
只是为了澄清 - 您是否获得输入文件、目标文件夹或目标文件的 FNFE?
-
SO 正在吃 cmets - Kevin_Jim 回复的评论包含链接:stackoverflow.com/questions/486494/…
-
@Kevin - 当然,至少这是一个类似的问题 - 我假设您在询问之前使用了 Search ;-) - 开个玩笑 - 另一个问题是由于缺少应用程序的用户访问权限引起的。
标签: java copy-paste filenotfoundexception