16 |
|
|
17 |
public class HttpUtil { |
public class HttpUtil { |
18 |
|
|
19 |
|
static public Map<String,String> decodeUri(String uri) { |
20 |
|
if (uri.indexOf('?') != -1) { |
21 |
|
String parts[] = uri.split("\\?"); |
22 |
|
return decodeParams( parts[1] ); |
23 |
|
} else { |
24 |
|
return new HashMap<String,String>(); |
25 |
|
} |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
} |
30 |
|
|
31 |
static public Map<String,String> decodeParams(String str) { |
static public Map<String,String> decodeParams(String str) { |
32 |
Map<String,String> res = new HashMap<String,String>(); |
Map<String,String> res = new HashMap<String,String>(); |
33 |
|
|
96 |
} |
} |
97 |
} |
} |
98 |
|
|
99 |
|
public static String getContentString(String uri, int timeout) throws IOException { |
100 |
|
return getContentString(uri, timeout, "UTF-8"); |
101 |
|
} |
102 |
|
|
103 |
|
public static String getContentString(String uri, int timeout, String encoding) throws IOException { |
104 |
|
byte[] buf = getContent(uri, timeout); |
105 |
|
return new String(buf, encoding); |
106 |
|
} |
107 |
|
|
108 |
public static byte[] getContent(String uri, int timeout) throws IOException { |
public static byte[] getContent(String uri, int timeout) throws IOException { |
109 |
URL url = new URL(uri); |
URL url = new URL(uri); |