-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpReader.java
35 lines (31 loc) · 953 Bytes
/
HttpReader.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
class HttpReader
{
public void HttpReader(String address) throws Exception {
URL page = new URL(address);
StringBuffer text = new StringBuffer();
HttpURLConnection conn = (HttpURLConnection) page.openConnection();
conn.connect();
InputStreamReader in = new InputStreamReader((InputStream) conn.getContent());
BufferedReader buff = new BufferedReader(in);
String line;
do {
line = buff.readLine();
text.append(line + "\n");
} while (line != null);
String ans = text.toString();
System.out.println(ans);
}
public static void main(String[] args) throws Exception
{
HttpReader hr = new HttpReader();
hr.HttpReader("http://dx-code.org/funny.htm");
}
}