Hello!
I want to do something similar (Send a file in bytes).
I am doing like that:
J2ME String requestString = "POST message";
hc = ( HttpConnection )Connector.open( url, Connector.READ_WRITE );
hc.setRequestMethod( HttpConnection.POST );
dos = hc.openDataOutputStream();
byte[] requestBody = requestString.getBytes();
dos.writeInt (requestBody.length);
dos.write(requestBody, 0, requestBody.length);
dos.writeUTF ("utf string");
Servlet's doPost is = request.getInputStream();
dis = new DataInputStream(is);
byte [] audiodata = null;
int length = dis.readInt();
dis.readFully(audiodata, 0, length);
String text = dis.readUTF ();
Then I send a response message back to the midlet
I receive a null pointer exception in
dis.readFully(audiodata, 0, length);
One time only (dont know why) I received an end of file exception in the same line!
the int and udf write/reading works ok (they are there for
testing)
any ideas please?