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();
		}

你可能感兴趣的:(http)