try {
System.setProperty( "http.proxyHost", "192.168.1.5" );
System.setProperty( "http.proxyPort", "8085" );
java.net.URL url = new java.net.URL( "http://www.3721.com/install/install.htm" );
URLConnection conn = url.openConnection();
InputStream sslin = conn.getInputStream();
InputStreamReader inReader = new InputStreamReader( sslin );
BufferedReader in = new BufferedReader( inReader );PrintStream out = new PrintStream( new FileOutputStream( "D:\\aa.txt" ) );
String line;
while ( null != ( line = in.readLine() ) ) {
out.println( line );
}
in.close();
} catch ( Exception e ) {
System.out.println( "error occured : " + e.getMessage() );
}
System.setProperty( "http.proxyHost", "192.168.1.5" );
System.setProperty( "http.proxyPort", "8085" );
java.net.URL url = new java.net.URL( "http://www.3721.com/install/install.htm" );
URLConnection conn = url.openConnection();
InputStream sslin = conn.getInputStream();
InputStreamReader inReader = new InputStreamReader( sslin );
BufferedReader in = new BufferedReader( inReader );PrintStream out = new PrintStream( new FileOutputStream( "D:\\aa.txt" ) );
String line;
while ( null != ( line = in.readLine() ) ) {
out.println( line );
}
in.close();
} catch ( Exception e ) {
System.out.println( "error occured : " + e.getMessage() );
}
System.setProperty( "http.proxyPort", "port" );
prop.put("http.proxyPort", proxyPort);
System.setProperties(prop);其中的proxyHost和proxyPort是代理服务器的地址和端口。