- import java.io.*;
- import java.net.*;
- public class URLDemo {
- public static void main(String[] args) throws IOException {
- URL url = new URL("http://www.baidu.com");
- URLConnection urlConnection = url.openConnection();
- InputStream inputStream = urlConnection.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); //用于读取数据
- String line = null;
- while ((line = br.readLine()) != null) {
- System.out.println(line); //就是这里,为什么好多内容都跑到一行去了?
- }
- br.close();
- }
- }
复制代码 为什么好多内容都到了一行去了。本来不是应该分好多行的吗 |