Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BufferedInputStream vs BufferedReader

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody please let me know when to use the BufferedReader and BufferedInputStream .
Because using both i can able to read the data from my Text Input File .

Bartenders please bare this time if this is a question not to posted .
so please share your ideas .
Thanks in advance .
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi Kiran V wrote:Can anybody please let me know when to use the BufferedReader and BufferedInputStream .
Because using both i can able to read the data from my Text Input File .

InputStream and all of its direct and indirect subclasses should be used for binary files, as it reads bytes. It can be used for text files if and only if the file's encoding uses exactly one byte for every character, like ASCII.
Reader and all of its direct and indirect subclasses should be used for text files, as it reads chars. It should never ever be used for binary files.

InputStream can also be used if you do not need to inspect the contents, like in copying files.

Bartenders please bare this time if this is a question not to posted .

Why should it not be posted? You didn't ask this question anywhere else (that I am aware of). The only reason could be that you could have found the answer by searching first.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic