public
static
void
main(String[] args) {
// TODO Auto-generated method stub
String CurrentLine = "" ;
String TotalString = "" ;
InputStream urlStream;
try {
URL url = new URL( " http://www.163.com " );
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.connect();
urlStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(
new InputStreamReader(urlStream, " gbk " ));
while ((CurrentLine = reader.readLine()) != null ) {
TotalString += CurrentLine + " " ;
}
String content = TotalString;
System.out.println(content);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// TODO Auto-generated method stub
String CurrentLine = "" ;
String TotalString = "" ;
InputStream urlStream;
try {
URL url = new URL( " http://www.163.com " );
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.connect();
urlStream = connection.getInputStream();
BufferedReader reader = new BufferedReader(
new InputStreamReader(urlStream, " gbk " ));
while ((CurrentLine = reader.readLine()) != null ) {
TotalString += CurrentLine + " " ;
}
String content = TotalString;
System.out.println(content);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}