• 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

method read() in InputStream class

 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when one calls the read() method, typically say in the System.in.read() then which read method is being called and from where ? because the read() method is abstract (as mentioned in the api).
the other read methods in InputStream class
read(byte[] b) and read(byte[] b, int off, int len) are not abstract though. I know that they are not being called, ijust mentioned it because my next question deals with this.
second question about the buffer b. We could access the array b ? right ? is this why this buffer has been provided so that one may access the contents of this buffer ? if not what is the purpose.
 
mark stone
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
List i need your help with this one.

Originally posted by mark stone:
when one calls the read() method, typically say in the System.in.read() then which read method is being called and from where ? because the read() method is abstract (as mentioned in the api).
the other read methods in InputStream class
read(byte[] b) and read(byte[] b, int off, int len) are not abstract though. I know that they are not being called, ijust mentioned it because my next question deals with this.
second question about the buffer b. We could access the array b ? right ? is this why this buffer has been provided so that one may access the contents of this buffer ? if not what is the purpose.

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I THINK the buffer is there so that you can have access to those bytes. You pass the array object to the read method and it fills it for you.
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is some code:

Hope this helps!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic