赞
踩
1 packagecom.yulv.utils;2
3 importjava.io.BufferedReader;4 importjava.io.IOException;5 importjava.io.InputStream;6 importjava.io.InputStreamReader;7 importjava.io.OutputStream;8 importjava.io.OutputStreamWriter;9 importjava.net.HttpURLConnection;10 importjava.net.InetSocketAddress;11 importjava.net.Proxy;12 importjava.net.URL;13 importjava.net.URLConnection;14 importjava.util.Iterator;15 importjava.util.Map;16
17
18 public classHttpRequestor {19 private String charset = "utf-8";20 private Integer connectTimeout = null;21 private Integer socketTimeout = null;22 private String proxyHost = null;23 private Integer proxyPort = null;24
25 /**
26 * Do GET request27 *@paramurl28 *@return
29 *@throwsException30 *@throwsIOException31 */
32 public String doGet(String url) throwsException {33
34 URL localURL = newURL(url);35
36 URLConnection connection =openConnection(localURL);37 HttpURLConnection httpURLConnection =(HttpURLConnection)connection;38
39 httpURLConnection.setRequestProperty("Accept-Charset", charset);40 httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");41
42 InputStream inputStream = null;43 InputStreamReader inputStreamReader = null;44 BufferedReader reader =
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。