Есть код
URL url = new URL("http://vk.com");
BufferedInputStream inputStream = new BufferedInputStream(url.openStream());
FileOutputStream outputStream = new FileOutputStream("pathToSave/1.html");
byte[] buffer = new byte[4096];
while (inputStream.read(buffer) > 0) {
outputStream.write(buffer);
}
inputStream.close();
outputStream.close();
При запуске(в ide(idea), в командной строке), программа выбрасывает исключение
D:\Clouds\Dropbox\Projects\IdeaProjects\DownloadAgent\out\artifacts\DownloadAgen
t_jar>"C:\Program Files\Java\jre7\bin\java.exe" -jar DownloadAgent.jar
Exception in thread "main" java.net.UnknownHostException: vk.com
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
ce)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
urce)
at java.net.URL.openStream(Unknown Source)
at com.redprojects.net.downloadAgent.Main.main(Main.java:14)
Ошибка выбрасывается при любом url.
Уже и JDK менял(юзал и 8 и 7 версии). Ничего не помогает.