• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IOException on outputStream close on Nokia

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic