wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes FileOutputStream and JPG file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FileOutputStream and JPG file." Watch "FileOutputStream and JPG file." New topic
Author

FileOutputStream and JPG file.

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I use Applet to send a file to Servlet. Now my coding is only working for Text and small GIF icon. The saved file, if it is in JPG and large GIF file, will be corrupted.

How to fix it ?

Thanks.

applet : send a file


Servlet : receive a file
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
Binary data (like an image file) is not character data - you can't convert it to a string. Just do a "out.write(buffer1, 0, bytesRead)" instead.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
We like to reserve this forum for "easy" questions, so I feel I shall have to move this thread.
Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
Ulf Dittmer wrote:Binary data (like an image file) is not character data - you can't convert it to a string. Just do a "out.write(buffer1, 0, bytesRead)" instead.

Thanks. it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FileOutputStream and JPG file.