• Post Reply Bookmark Topic Watch Topic
  • New Topic

IOException on outputStream close on Nokia  RSS feed

 
R Briggs
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bigsly,

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

JavaRanch Naming Policy

Thank you

cheers
Michael
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!