Java's IO class operations mainly include the following categories
1, the use of the file class.
2, byte operation flow: OutputStream, InputStream
3, character operation Flow: Reader, Writer
4. Serialization of objects: Serializable
InputStream
The InputStream read stream has 3 methods, respectively
First: Abstract int read ()
Reads a single byte from this stream and returns it as an integer in the range from 0 to 255.
Reads one byte from the stream at a time and represents the byte as an integer type of 0 to 255. (for example, Chinese characters, which are split into two bytes and represented as an integer type, become two numbers)
Instance:
public class Test { public static void main (string[] args) {String String = "Test using" ; byte [] bs=string.getbytes (); System.out.print (bs.length + "" ); for (int i = 0; i < bs.length; i++ +" new String (BS) ); }}
Results: 8-78-30-54-44-54-71-45-61 test use
Second: int read (byte[] buffer)
Equivalent to read (buffer, 0, buffer.length).
Equal to read (buffer, 0, buffer.length)
Third: int read (byte[] buffer, int offset, int length)
Reads at more than length bytes from this stream and stores them in the byte array b starting at offset.
Reads the length of bytes from the stream and puts it into the B array starting at the offset position.
where the Read () method reads one byte at a time, the efficiency is very low. So it is best to use the following two methods.
Java--io operation