I am using jxa-1.0 to create Instant Messaging application in blackberry while running the application i m getting exception like "java.io.IOException: S开发者_开发问答tream closed".Could you please tell me how to fix this?? or if u have prior experience with Jxa-1.0 pls share your ideas about how to use this one.
If you want to avoid this error on simulators, you should read the InputStream one byte at a time, try this code (consider NOT using this method when working with a real device, since performance will be affected):
InputStream is = httpConnection.openInputStream();
int data = -1;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
data = is.read();
bos.write(data);
while (data >= 0) {
try {
data = is.read();
} catch (Exception e) {
// Replace exception with "-1". This is to handle anomalous End-of-Stream in OS 5.
data = -1;
}
bos.write(data);
}
byte[] byteArray = bos.toByteArray();
If you are seeing this error message in a simulator, don't be surprised. I see I/O errors like this quite often in simulators, especially over Direct TCP or Wi-Fi connections. Some of the newer 5.0 simulators seem to be more problematic than older ones.
If you haven't yet, try it on a real device and it will probably be better.
精彩评论