`

http get请求

 
阅读更多
HttpClient httpClient = new HttpClient();
		HttpMethod getMethod = new GetMethod();
		
		String respFlag = null;
		try {
			getMethod.setURI(new URI(url));
			int sendFlag = httpClient.executeMethod(getMethod);
			if (sendFlag != HttpStatus.SC_OK) {
				System.out.println("send mobile message fail!");
				return "fail";
			}
			
			System.out.println(new String(getMethod.getResponseBodyAsString().getBytes(),"GBK"));
			
		} catch (IOException e) {
			e.printStackTrace();
		}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics