Java Reference
In-Depth Information
concrete and one is abstract. The first implementation of write() has the
followingprototype:
public abstract void write(int b)
throws IOException
The method writes the specified byte to the current output stream. The
byte to be written is defined as the eight low-order bits of the argument b,
which is of type int. The 24 high-order bits are ignored. Subclasses of
OutputStreamprovidetheimplementationofthismethod.AnIOException
israisedifanI/Oerroroccursoriftheoutputstreamhasbeenclosed.
Thesecondimplementationhasthefollowingprototype:
public void write(byte[] b)
throws IOException
This method writes b length bytes from the byte array passed as an ar-
gument to the current output stream. The method raises an IOException
ifanI/Oerroroccurs.
Thethirdimplementationisprototypedasfollows:
public void write(byte[] b, int o, int l),
throws IOException
This method writes l number of bytes, from the byte array specified as an
argument,startingatoffseto,tothecurrentoutputstream.Thisvariationof
the write() method of OutputStream calls the write() method on each of the
bytestobewritten.Subclassesoverridethismethodandprovideamoreeffi-
cient implementation. If the array passed as an argument is null, a
NullPointerException is thrown. If o is negative, or l is negative, or o + l is
greater than the length of the array b, then an IndexOutOfBoundsException
is thrown. An IOException is raised if an I/O error occurs or if the output
streamisclosed.
Standard Streams
Applicationsoftenusethekeyboardastheinputstreamandthedisplaysys-
temasanoutputstream.Inthiscaseitissaidthatthekeyboardisthestan-
dard device for console input, and that the video display is the standard
device for console output. In addition, an error stream is provided for di-
rectingerrormessagesduringdebugging.TheSystemclassinthejava.lang
package contains three fields that relate to the standard streams, as fol-
lows:
public static final InputStream in;
// Standard input
Search WWH ::




Custom Search