Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

ByteArrayInputStream confusion

Thread view: 
Sard - 05 Mar 2007 21:52 GMT
The ByteArrayInputStream class has a read method which is "the buffer
into which the data is read".  How can this be possible if arguments
are always passed by value?

read

public int read(byte[] b,
               int off,
               int len)

   Reads up to len bytes of data into an array of bytes from this
input stream. If pos equals count, then -1 is returned to indicate end
of file. Otherwise, the number k of bytes read is equal to the smaller
of len and count-pos. If k is positive, then bytes buf[pos] through
buf[pos+k-1] are copied into b[off] through b[off+k-1] in the manner
performed by System.arraycopy. The value k is added into pos and k is
returned.

   This read method cannot block.

   Overrides:
       read in class InputStream

   Parameters:
       b - the buffer into which the data is read.
       off - the start offset of the data.
       len - the maximum number of bytes read.
   Returns:
Michael Rauscher - 05 Mar 2007 22:00 GMT
Sard schrieb:
> The ByteArrayInputStream class has a read method which is "the buffer
> into which the data is read".  How can this be possible if arguments
> are always passed by value?

The buffer you're referring to is an array of bytes (byte[]).

In Java arrays are objects. So the reference to that object (array) is
passed by value.

Bye
Michael


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.