This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FileOutputStream and JPG file.

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 51418
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We like to reserve this forum for "easy" questions, so I feel I shall have to move this thread.
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic