readUTF超时

时间:2010-04-21 13:45:39

标签: java json blackberry twitter

我在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();

1 个答案:

答案 0 :(得分:1)

DataInputStream仅用于通过Java在另一端序列化的流中反序列化Java对象。我怀疑你真正想要的是:

InputStream is = hc.openInputStream();
String list = new String(IOUtilities.streamToBytes(is));