• Post Reply Bookmark Topic Watch Topic
  • New Topic

Two simple BufferedReader questions  RSS feed

 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning character based stream on java. In the book the first thing they are introducing me to is,

I understand that InputStreamReader converts byte based input into characters, and (my assumption is) BufferReader concatenate those individual characters to a Stream(String?)

Now I have two question,

1. Is my assumption correct about BufferedReader?

2. And what does the Buffer keyword on BufferedReader mean?
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quazi Irfan wrote:
I understand that InputStreamReader converts byte based input into characters, and (my assumption is) BufferReader concatenate those individual characters to a Stream(String?)

Now I have two question,

1. Is my assumption correct about BufferedReader?

2. And what does the Buffer keyword on BufferedReader mean?

A BufferedReader reads characters from a character input stream (in this case an InputStreamReader) and buffers the characters to make reading more efficient. The BufferedReader also provide an additional convenience method to read a line of data at a time.
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
A BufferedReader reads characters from a character input stream (in this case an InputStreamReader) and buffers the characters to make reading more efficient.


So InputStreamReader is converting the byte stream(InputStream) to characters and feeding it to BufferedReader, and BufferedReader is buffering them?

What is buffering? and why buffering makes it easier to reading the characters more efficient?
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quazi Irfan wrote:What is buffering? and why buffering makes it easier to reading the characters more efficient?


Read the Wikipedia article about buffering: Data buffer.
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Read the Wikipedia article about buffering: Data buffer.


I've read it, but my question was why use the word buffer. What's in this word 'buffer' that suits it, more than any other words, when talking about temporary storage.
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why a buffer is called a "buffer". I don't know why a chair is called a "chair" either... is it important for you to know the derivation or etymology of the word?
 
Tony Docherty
Bartender
Posts: 3264
81
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quazi Irfan wrote:but my question was why use the word buffer. What's in this word 'buffer' that suits it, more than any other words, when talking about temporary storage.

Because, in computer terminology, 'buffer' has been accepted as meaning a place to temporarily store data whilst processing or transferring it. If you want more information on it I suggest you search online/read dictionaries etc.
 
Quazi Irfan
Ranch Hand
Posts: 104
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony Docherty wrote:
Quazi Irfan wrote:but my question was why use the word buffer. What's in this word 'buffer' that suits it, more than any other words, when talking about temporary storage.

Because, in computer terminology, 'buffer' has been accepted as meaning a place to temporarily store data whilst processing or transferring it. If you want more information on it I suggest you search online/read dictionaries etc.


Thank you. That cleared things up.

On stackoverflow I have found a simple explanation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!