• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

buffer?

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A buffered input stream fills a buffer with data that hasn’t been handled yet. When a program
needs this data, it looks to the buffer first before going to the original stream
source.Buffered byte streams use the BufferedInputStream and BufferedOutputStream
classes.



Buffered Reader Class (java.io.*)
A buffer stores keys from the InputStreamReader it in an allocated memory area called a buffer.
Your program will read characters from the buffer rather than directly from the device. This relieves
the input device from being accessed every time data is required from the program.



Are these Buffer same? Is this the same buffer that if fills too much make "Buffer Overflow"?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A "buffer" is a general concept; it's not one specific memory location, or anything like that. BufferedReader, BufferedInputStream, etc, each have an array inside which acts as the buffer for that object. Your operating system will maintain its own buffers for various purposes.

"Buffer overflow" means that there is more data to be stored than will fit in the fixed-sized buffer being used in some particular situation. It could arise in many different contexts.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

BufferedReader, BufferedInputStream, etc, each have an array inside which acts as the buffer for that object.






You mean in above code, When BufferedReader object is created, Is an array create inside it that saves data?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the BufferedReader has a member variable that is an array of char.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You realise there is a potential error in your reading? You are not closing the Reader when you have finished with it. You should close Readers and Writers in finally blocks, so as to ensure they are closed whether an Exception occurs or not.
 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ernest!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic