两种HTTP连接方式POST&GET的比较(3)
// Opening the InputStream will open the connection
// and read the HTTP headers. They are stored until
// requested.
is = c.openInputStream();
// Get the ContentType
String type = c.getType();
processType(type);
// Get the length and process the data
int len = (int)c.getLength();
if (len > 0) {
byte[] data = new byte[len];
int actual = is.read(data);
process(data);
} else {
int ch;
while ((ch = is.read()) != -1) {
process((byte)ch);
}
}
} finally {
if (is != null)
is.close();
if (os != null)
os.close();
if (c != null)
c.close();
}
}
相关新闻>>
- 发表评论
-
- 最新评论 更多>>