java环境问题 爱java的进来下
本帖最后由 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;
int len = inputStreamReader.read(cha);
System.out.println(new String(cha,0,len));
inputStreamReader.close();
//释放连接
method.releaseConnection();
}
}
一个HTTP请求例子.
电脑Eclipse测试通过,pi不行
编译通过运行创建环境失败.
刚入手pi不是很懂,请教.
没装jvm? 我也不是很懂哈
页:
[1]