我需要在我的应用程序中设置没有代理的条件;为此,我使用了以下代码:
URL url = null;
try {
url = new URL(uri.toURL().toString());
} catch (MalformedURLException e3) {
e3.printStackTrace();
}
try {
//client = (HttpURLConnection) url.openConnection(java.net.Proxy.NO_PROXY);
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.nonProxyHosts",ServerIP);
systemProperties.setProperty( "proxySet", "false" );
systemProperties.setProperty("http.proxyHost","");
systemProperties.setProperty("http.proxyPort","");
URLConnection conn = url.openConnection(Proxy.NO_PROXY);
conn.connect();
} catch (IOException e3) {
e3.printStackTrace();
}
但是我遇到了网络无法访问的异常!!
任何帮助!