File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method read() in InputStream class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method read() in InputStream class" Watch "method read() in InputStream class" New topic
Author

method read() in InputStream class

mark stone
Ranch Hand

Joined: Dec 18, 2001
Posts: 417
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

Joined: Dec 18, 2001
Posts: 417
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.
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
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 R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Here is some code:

Hope this helps!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method read() in InputStream class
 
Similar Threads
question about InputStream
Abstract Method
Why do we have concrete methods in abstract class ?
How to encode image in parts?
read() method question (reposting)