BufferedReader 를 이용하여 html 내용 출력
package http.test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
public class Reader {
public static void main(String[] args) throws Exception {
URL url = new URL("http://www.w3.org/");
InputStream is = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"));
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
is.close();
}
}
댓글 없음:
댓글 쓰기