ITeye博客

URL类发起http请求

henu_zhangyang · 2017-05-03 20:10 · java · 开源软件 · URL · HttpPost · Markdown

    public static void doPost(String path){
        InputStream in = null;
        try {
            URL url=new URL(path);
            in = url.openConnection().getInputStream();
            String content= org.apache.commons.io.IOUtils.toString(in);
            System.out.println("content is " + content);
        } catch (IOException e) {
            System.err.println("error !");
            e.printStackTrace();
        }
    }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。