aspose file tools*
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
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: 39548
    
  27
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 - updated with new look and Ping home screen widget
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
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.
 
Similar Threads
copying files over a network
Using Apache Commons Codec
Sending a file over socket
Socket connection program works for localhost but not for other ip
Transferring file name then file data over socket