日期:2014-05-17 浏览次数:20675 次
String strURL = "http://statutes.agc.gov.sg/aol/browse/yearResults.w3p;type=actsSup;year=2006";
URL url;
url = new URL(strURL);
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
InputStream inStream = httpConn.getInputStream();
GZIPInputStream gzipStream = new GZIPInputStream(inStream);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = -1;
while ((len = gzipStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
byte[] data = outStream.toByteArray();
outStream.close();
gzipStream.close();
inStream.close();
System.out.println(new String(data, "utf-8")); ;