0
此代碼應下載網頁指定的圖像,但將在線程「主要」 javax.net.ssl.SSLProtocolException圖片下載Java中
例外:握手警報:unrecognized_name
請幫助我。我使用NetBeans 7.1.1進行了測試。
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class Download {
public static void main(final String[] args) throws Exception {
String fileName = "Google_logo.png";
String website = "https://img3.wikia.nocookie.net/cb20100520131746/logopedia/images/5/5c/" + fileName;
System.out.println("Downloading File From: " + website);
URL url = new URL(website);
InputStream inputStream = url.openStream();
OutputStream outputStream = new FileOutputStream(fileName);
byte[] buffer = new byte[2048];
int length;
while ((length = inputStream.read(buffer)) != -1) {
System.out.println("Buuffer Read of length :" + length);
outputStream.write(buffer, 0, length);
}
inputStream.close();
outputStream.close();
}
}