Forums Register Login

IOException on outputStream close on Nokia

+Pie Number of slices to send: Send
I am having trouble with my client outputStream code on a Nokia 6225. The code works everytime on other devices (Sanyo,Samsung) but thows an IOException error when I try to close (or flush) the outputStream. The server I connect to recieves the information fine so I don't think the error is there, plus the server has not changed, only the device. Its basic connection code:
try {
conn = (HttpConnection) Connector.open(someurl, Connector.READ_WRITE, true);
conn.setRequestMethod(HttpConnection.POST);
conn.setRequestProperty("Content-Type", "text/html");
conn.setRequestProperty("Connection","close");
conn.setRequestProperty("Content-Length", Integer.toString(request.msg.getBytes().length ));
out = conn.openOutputStream();
out.write(request.msg.getBytes());

//RECEIVE ERROR ON NEXT STATEMENT//
out.close();
out = null;

StringBuffer responseBuf = null;
in = null;
in = conn.openInputStream();

long length = (long) conn.getLength();
responseBuf = new StringBuffer();
int ch;
if (length > 0) {
for (int i = 0; i < length && (ch = in.read()) != -1; i++) {
responseBuf.append( (char) ch);
}
}
else {
while ( (ch = in.read()) != -1) {
responseBuf.append( (char) ch);
}
}

response = responseBuf.toString();

} catch (Exception e) {
//HANDLE EXCEPTIONS HERE

Does anyone have any ideas on why this happens and maybe some advice on how to fix the problem?

Thanks in advance.
[ December 09, 2004: Message edited by: Rae Briggs ]
+Pie Number of slices to send: Send
bigsly,

Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy

Thank you

cheers
Michael
Won't you be my neighbor? - Fred Rogers. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1027 times.
Similar Threads
how to send email from j2me using Servlets
Odd Problem - HttpConnection functionality
HTTP connection thread problem to SERVLET on APACHE
servlet response
J2se server and J2me client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:19:43.