Not able to write to file
Hi all,
I need to upload a file from a J2ME device to a remote server using a servlet
I am uploading an image ..and in the servlet i get the size of the file but i am not able to write to that file...please see code below...any help would be great.
Thanks in advance
StringBuffer bufferBody=new StringBuffer();
String line="";
byte[] data = new byte[79872000];
int cnt=0;
try
{
BufferedReader body=request.getReader();
while ((line = body.readLine()) != null) {
bufferBody.append(line);
cnt++;
}
data = bufferBody.toString().getBytes();
System.out.println("data received:"+data+"data length:"+data.length+"lines"+cnt);
String newFileName = "/home/aztec/pic2.jpg";
//data="hi".getBytes();
FileOutputStream imageOutput = new FileOutputStream(new File(newFileName));
imageOutput.write(data, 0, data.length);
imageOutput.close();
System.out.println("Please find image in " + newFileName);
} catch(Exception ex) {
System.out.println("Exception: " + ex);
ex.printStackTrace();
}

