tags:

views:

15

answers:

0

Hi, I'm sending an image file from an iPhone application to a http Post application. The Post application is a java restful web service that accepts Post requests. I have the Post method receiveing a byte array and then writing it to a file like this:

private void writeToFile(byte[] str) {
String strFilePath = "/Users/j/Desktop/joe.png";

try
{
 FileOutputStream fos = new FileOutputStream(strFilePath);

  fos.write(str);
  fos.close(); 
}
}

the file writes successfully to my local disk but when i attempt to open the file it is not viewable. I get an error that it can't be open and may be damaged. Does anyone know why I can't view this image?