Java know how much (69) byte-oriented input and output stream

Source: Internet
Author: User
Tags java throws

The byte stream, in bytes, is used to read and write 8 bits of data, in addition to the ability to handle plain text files, but also to process binary data. The InputStream class and the OutputStream class are the parent classes for all byte streams. The InputStream class byte-oriented input stream is a subclass of the InputStream class, as shown in class hierarchy 10-6.
Figure 10-6 class hierarchy diagram for InputStream
Table 10-5 lists the main subclasses and descriptions of the InputStream.
Table 10-5 Primary subclasses of InputStream
class name function Description
FileInputStream The input stream read from the file
PipedInputStream Input piping
FilterInputStream Filter input Stream
Bytearrayinputstream The input stream read from the byte array
Sequenceinputstream A federated input stream of two or more input streams, read sequentially
ObjectInputStream The input stream of the object
Linenumberinputstream Append line number for text file input stream
DataInputStream Input stream containing methods for reading Java standard data types
Bufferedinputstream Buffered input stream
Pushbackinputstream Returns a byte and puts this byte back into the input stream

The InputStream Stream class contains a set of methods that all inputs require to perform the most basic functions of reading data from an input stream. Table 10-6 lists the commonly used methods and descriptions.
if there is no data at the current position in the input stream
Table 10-6 Common methods for InputStream
method Feature description
void Close () Close input stream
void Mark () marks the current position of the input stream
void Reset () returns the read position to the marker
int Read () reads a byte of binary data from the current position in the input stream, which is a low byte, returns after 16-bit integer (0~255), and returns 1
int Read (byte b[]) reads consecutive bytes from the current position in the input stream into the array and returns the number of bytes read
int Read (byte b[], int off, int len) reads len long bytes from the current position in the input stream, starts at the off+1 element position of the array, and returns the number of bytes read
int available () Returns the number of bytes that can be read in the input stream
Long Skip (long N) slightly over n characters Section
Long Skip (long N) skips n characters within a stream
boolean marksupported () test whether the input data flow supports markup
The byte-oriented output stream of the OutputStream class is a subclass of the OutputStream class, as shown in class hierarchy 10-7.
Figure 10-7 class hierarchy diagram for OutputStream
10-7 lists the main subclasses and descriptions of the outputstream.
Table 10-7 Primary subclasses of OutputStream
class name function Description
FileOutputStream Output stream written to file
PipedOutputStream Output piping
Filteroutputstream Filtering the output stream
Bytearrayoutputstream Writes the output stream of a byte array
ObjectOutputStream The output stream of the object
DataOutputStream Output stream containing methods for writing Java standard data types
Bufferedoutputstream Buffered output stream
PrintStream Output stream with print () and println ()

The OutputStream Stream class contains a set of methods that all outputs require to perform the most basic function of writing data to the output stream. Table 10-8 lists the commonly used methods and descriptions.
Table 10-8 Common methods of OutputStream
Method function Description
void Close () Turn off the output stream
void Flush () Force empty buffer and perform output data to peripheral
void write (int b) Writes the low byte of parameter B to the output stream
void write (byte b[]) Writes all bytes in the array b[] to the output stream sequentially
void write (byte b[], int off, int len) Writes the Len data starting with the Off+1 element in the array b[] to the output stream sequentially

Since both InputStream and OutputStream are abstract classes, the input stream objects created in the program are generally objects of one of their subclasses, and the input and output operations on the corresponding peripherals can be achieved by invoking the read () and write () methods inherited by the object. Series Articles:Java know how much (top)Java know how much (interface) interfaceJava knows how much (40) the difference between an interface and an abstract classJava know how much (41) generic explanationJava know how much (42) the range of generic wildcard characters and type parametersJava know how much (43) Exception Handling BasicsJava know how much (44) exception typeJava know how much (45) uncaught ExceptionsHow much Java knows (the) use of try and catchJava know how much (47) use of multiple catch statementsJava knows how much (in) the nesting of try statementsJava know how much (a) Throw: Exception throwsJava know how many () Java throws clausesJava knows how many (or) finallyJava know how much (52) built-in exceptionsJava know how much (53) Use Java to create your own exception subclassesJava know how much (54) assertion detailedJava know how many (55) threadsJava know how much (56) threading ModelJava know how much (57) main threadJava know how much (58) thread Runnable interface and thread class explanationJava know how much (59) Create multithreadingJava know how much (isAlive) and join () useJava know how much (61) thread PriorityJava know how much (62) thread synchronizationJava know how much (63) inter-thread communicationJava know how much (64) thread deadlockJava know how much (65) thread hangs, resumes, and terminatesJava know how much (66) Overview of input and output (IO) and streamsJava know how much (67) character-oriented input streamJava know how much (68) character-oriented output stream

Java know how much (69) byte-oriented input and output stream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.