Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the meaning of file containing byte datas?

 
Dash Abhisek
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have encountered this particular line saying "go for reader and writer when the file is having character datas and go for InputStream and OutputStream when the file contains byte datas"
now my question is what is a byte data? do they want to say "byte code" or file containing numbers from -128 to +127(byte range).
please help how to identify byte datas?

Thanks a lot
 
Dash Abhisek
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,

Please help any link will also do.

Thanks
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All files are binary data (ones and zeros). Some files contain binary data which can be interpreted as characters. These would be ASCII text or Unicode encoded files. We use Readers/Writers on these files because they do the conversion between the file encoding and the Java representation as characters and Strings (see this page for more). All other files are binary files. A binary file could contain a single JPEG image or a bunch of individual records. It could be a database file or a Word document. The point is, it can't be interpreted as text.
 
Dash Abhisek
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

Lots of thanks for the help, I almost got it after going through your explanation , files like sound files(.mp3), image files whose contents are not normal characters are all read through inputstream and files which contains characters are read through readers (I hope I am correct this time).

I got one doubt and that is if every file is a binary file why don't we use inputstreams all the time?I hope this is a valid doubt.

Thanks


 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dash Abhisek wrote:
I got one doubt and that is if every file is a binary file why don't we use inputstreams all the time?


Convenience. If we are reading a text file, we probably want to deal with Strings and not byte arrays which we have to take the extra step of converting into Strings.
Keep in mind that we don't always use Readers/Writers on text files. If we are just moving data and don't have to process it, it is faster to use a stream than a reader because no conversion takes place. Copying a file or uploading data using a socket are examples where we aren't processing the data, just moving it.
 
Dash Abhisek
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the help
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!