Webサイトからコードをダウンロードして、コードが正常に動作しないため、エラーが表示されず、ドキュメントが読み込まれますが、ドキュメントにはhmtlがありません。コンテンツ...Java:URLからの.txtファイル
public static void main(String[] args) {
try {
URL website = new URL("http://www.file-upload.net/download-11700212/document.txt.html");
String filepath = "C://Users//" + System.getProperty("user.name") + "//Desktop//document.txt";
ReadableByteChannel channel = Channels.newChannel(website.openStream());
FileOutputStream stream = new FileOutputStream(filepath);
stream.getChannel().transferFrom(channel, 0, Long.MAX_VALUE);
System.out.println("Download successfull.");
} catch (Exception e) {
System.out.println("Download was not successfull.");
}
}
ダウンロード自体は動作しますが、私は自分のデスクトップ上のtxtファイルを得たが、内容は間違っているとhtmlコードがいっぱいです。
これは公式のリンクです: – Alex
http://www.file-upload.net/download-11700212/document.txt.html – Alex