This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FileOutputStream and JPG file.  RSS feed

 
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
 
Rancher
Posts: 42975
76
  • 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.
 
Sheriff
Posts: 57876
178
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!