查看: 1541|回复: 1
收起左侧

java环境问题 爱java的进来下

2015-1-16 22:35:43 | 显示全部楼层 |阅读模式
本帖最后由 dhyjvpn 于 2015-1-16 22:39 编辑

import java.io.BufferedReader;
import java.io.IOException;   
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.commons.httpclient.*;   
import org.apache.commons.httpclient.methods.*;

public class SimpleClient {   
    public static void main(String[] args) throws IOException   
   {   
            MultiThreadedHttpConnectionManager connectionManager =     
                               new MultiThreadedHttpConnectionManager();
            HttpClient client = new HttpClient(connectionManager);
            HttpMethod method = new GetMethod("http://www.baidu.com");
            client.executeMethod(method);   
        //打印服务器返回的状态   
            System.out.println(method.getStatusLine());            
            InputStreamReader inputStreamReader = new InputStreamReader(method.getResponseBodyAsStream());
            //打印返回信息一:
    //        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
    //        String line = null;  
    //    while((line = bufferedReader.readLine())!=null){  
    //         System.out.println(line);  
    //    }  
    //    inputStreamReader.close();  
            //打印返回信息二:
            char []cha = new char[5];
            int len = inputStreamReader.read(cha);
            System.out.println(new String(cha,0,len));  
            inputStreamReader.close();
       //释放连接   
            method.releaseConnection();            
   }

}
一个HTTP请求例子.
电脑Eclipse测试通过,pi不行

QQ图片20150116223039.jpg
编译通过运行创建环境失败.
刚入手pi不是很懂,请教.































Httpclient_jar.rar

353.91 KB, 下载次数: 0

jar包

回复

使用道具 举报

2015-1-19 11:43:50 | 显示全部楼层
没装jvm? 我也不是很懂哈
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热点推荐

关注我们,了解更多

官方微信

服务时间:10:00-16:00

13714503811

公司地址:深圳市龙岗区南湾街道东门头路8号

Copyright © 2012-2020 Powered by 树莓派论坛 2019.4  粤ICP备15075382号-1
快速回复 返回列表 返回顶部