这是代码。
package downloader;
import java.net.MalformedURLException;
import java.net.URL;
import java.io.File;
import java.io.IOException;
public class JustATest {
public static void main(String[] args) throws IOException {
File file = new File("D:" + "//" + "Hunter x Hunter 340 - 00 - créditos.jpg");
URL url = new URL("http://leitor1.mangasproject.com/3e1e967e9b793e908f8eae83c74dba9bcccce6a5535b4b462bd9994537bfe15c/1c96b0ef48b44ff71102d96f7ac2b515a0b7be31d04d7420f3d133d923189953/Hunter x Hunter 340 - 00 - créditos.jpg");
org.apache.commons.io.FileUtils.copyURLToFile(url, file);
}
}
运行此代码时出现此错误:
Exception in thread "main" java.io.FileNotFoundException: http://leitor1.mangasproject.com/3e1e967e9b793e908f8eae83c74dba9bcccce6a5535b4b462bd9994537bfe15c/1c96b0ef48b44ff71102d96f7ac2b515a0b7be31d04d7420f3d133d923189953/Hunter x Hunter 340 - 00 - créditos.jpg
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1460)
at downloader.JustATest.main(JustATest.java:14)
我试着用
InputStream in = new BufferedInputStream(url.openStream());
但这也没有用。
编辑:我现在必须说,在 NetBeans 中所有代码都可以正常工作,但是,我在 Eclipse 中编码。:( 我也必须说这个主机的大部分文件在 Eclipse 中都可以正常工作。