扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:mikko 来源:ibm 2007年11月21日
关键字:
HttpConnection con = null;
InputStream is = null;
String xml = new String();
OutputStream out = null;
try {
con = (HttpConnection)Connector.open(this.url);
con.setRequestMethod(HttpConnection.GET);
con.setRequestProperty( "Connection", "close" );
// The call to openInputStream() opens the connection
is = con.openInputStream();
// Read the XML file
ByteArrayOutputStream bas = new ByteArrayOutputStream();
int ch;
while ((ch = is.read()) != -1) {
bas.write(ch);
}
// The
xml = bas.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null!=out) out.close();
if (null!= is) is.close();
con.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
|
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。