java模拟解析器

package cn.dss.studay网络编程.mytomcat.URLDemo;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class URLDemo {
    /**
     * 模拟解析器
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        URL url = new URL("http://127.0.0.1:8080/myweb/1.html");

        final InputStream inputStream = url.openStream();

        final byte[] bytes = new byte[1024];

        final int read = inputStream.read(bytes);

        String text=new String(bytes,0,read);

        System.out.println(text );
        inputStream.close();
    }
}
发布了110 篇原创文章 · 获赞 16 · 访问量 6505

猜你喜欢

转载自blog.csdn.net/weixin_43319279/article/details/105738052