Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why cannot we read a .jpg file character by character although a pdf file can be read  RSS feed

 
Anchit Jindal
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a program in java which reads a file character by character and then copies the contents of that file in a newly created file. I tried this for an image file(.jpg). But surprisingly in the copied version of file the image was distorted. Why it happens so although when I opened the both files in notepad the contents of both the files were same.

The same is not happening with .pdf files....

Why it happens so??? Please explain...I am missing something conceptual...
Thanks a lot...
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't treat binary data (like images and PDFs) the same as character data - it simply isn't the same thing. It may occasionally work, but generally won't (definitely not for images).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!