---
title: "URL类发起http请求"
author: "henu_zhangyang"
date: "2017-05-03T20:10:07Z"
tags: ["HttpPost", "URL"]
categories: ["开源软件"]
slug: "url-http"
draft: false
lastmod: "2017-05-03T20:10:07Z"
id: 2372498
url: "https://ihenu.iteye.com/blog/2372498"
---

```
    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();
        }
    }
```