スキップしてメイン コンテンツに移動

投稿

ラベル(Proxy)が付いた投稿を表示しています

Eclipseでproxy設定

eclipseのplugin updateなどのために、eclipseから外部サイトにアクセスする必要があるかと思います。 ネットワークの設定の関係でproxyを通してアクセスしなければならない場合の、eclipseの設定方法を説明します。 Windows->Preferences->General->Network ConnectionsからActive ProviderでManualを選択 HTTPのProxy Hostにプロキシのホスト、Portにプロキシのポート番号を設定

Java: How to Set Proxy on HttpURLConnection

If you need to set proxy address on Java HttpURLConnection. Do something like below. public static String getString(String urlStr) throws Exception { HttpURLConnection connection = null; InputStream is = null; try { URI uri = new URI(urlStr); // settin proxy String proxyHost = ""; // your proxy serever address int proxyPort = 8080; // your proxy port Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); // open connection with passing Proxy Object connection = (HttpURLConnection)uri.toURL().openConnection(proxy); connection.connect(); is = connection.getInputStream(); String content = toString(is); return content; } finally{ closeQuietly(is); if(connection != null) { connection.disconnect(); } } } private static String toString(InputStream is) throws IOException { byt