我在readUTF处使用以下代码获得超时。知道为什么吗?
hc = (HttpConnection) Connector.open("http://twitter.com/statuses/user_timeline/" + username + ".json");
int rc = hc.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}
DataInputStream dataInputStream = hc.openDataInputStream();
String list = dataInputStream.readUTF();
答案 0 :(得分:1)
DataInputStream仅用于通过Java在另一端序列化的流中反序列化Java对象。我怀疑你真正想要的是:
InputStream is = hc.openInputStream();
String list = new String(IOUtilities.streamToBytes(is));