我在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();
最佳答案
DataInputStream仅用于从另一端由Java序列化的流中反序列化Java对象。我怀疑您真正想要的是这样的东西:
InputStream is = hc.openInputStream();
String list = new String(IOUtilities.streamToBytes(is));
关于java - readUTF超时,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2683425/