• Apache HttpClient FirstDemo


    import java.io.InputStream;
    
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.DefaultHttpClient;
    import org.apache.http.util.EntityUtils;
    
    
    /**
     * 
     * FileName HttpDemo.java  <br />
     * @author wenhao <br />
     * @version 1.0   <br />
     * @created 2013-1-10 下午7:02:08 <br />
     * 
     */
    
    /**
     * 
     * @author wenhao <br />
     * @version 1.0   <br />
     * @created 2013-1-10 下午7:02:08 <br />
     * 
     */
    public class HttpDemo {
        
        public static void main(String args[]) throws Exception{
            DefaultHttpClient http = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet("http://172.20.223.120/wenhao.txt");
            HttpResponse response = http.execute(httpGet);
            
            try {
                System.out.println(response.getStatusLine());
                HttpEntity entity = response.getEntity();
                InputStream input = entity.getContent();
                
                byte[] buf = new byte[1024];
                int len = input.read(buf);
                
                System.out.println(new String(buf, 0, len));
                EntityUtils.consume(entity);
            } catch (Exception e) {
                // TODO: handle exception
            } finally{
                httpGet.releaseConnection();
            }
        }
    
    }
  • 相关阅读:
    create joint
    delphi 使用parent让进度条上显示文字
    abSymMeshMEL.txt
    ini写配置信息
    CreateBindGroupNode.txt
    CreateaJointCurve.txt
    09 IKFKMatch.txt
    TIF_to_MAP.BAT
    ImportBVHv20.txt
    FormatDateTime 一段以时间为命令的代码
  • 原文地址:https://www.cnblogs.com/hnrainll/p/2855383.html
Copyright © 2020-2023  润新知