URL类发起http请求

阅读更多
    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();
        }
    }

 

你可能感兴趣的:(httppost,URL)