1224 Lessons Learned

I / O stream
I / O (Input / Output) stream, i.e., the input and output streams, is the basic input output implemented in java, he can easily achieve data input and output operations.
I / O streams there are many ways according to different classification can be divided into about three categories:
a byte stream and a stream of characters: the data units of different flow dividing operation of
the input and output streams: an ordered set of starting, end, a set of bytes, the assembly of the data transmission
node and the process flow stream: dividing the different functional stream.

Common methods byte stream and character stream
the InputStream: the FileInputStream
the PipedInputStream
DataInputStream
the outputStream: the FileInputStream
the PipedInputStream
DataInputStream
file
File class does not specify how the information read from a file or to a file storage; it describes the properties of the file itself. File object or process used to obtain information related to a disk file, such as authority, time, date, and directory path. In addition, File browse subdirectory hierarchy. Java directories as File treat it with additional attributes - can be a list () method to detect the list of file names.

File file itself
file operation class
the FileInputStream:
1.FileInputStream new new FIN = the FileInputStream ( "file path");
2.read (): each of a byte, returns a value of -1 when the end of file;
3.whlie ( ! (ch = fin.read ()) = - 1) the data file to read the file reaches the end of the cycle before the read data
4. (char) ch; read data returned by the default type int, it is returned ascii code value, and therefore a cast
5.byte BUFF [] = new new byte [1024]
6.new string (BUFF): string
after completion of file reading, to close the flow close () method

Guess you like

Origin blog.51cto.com/14589602/2461518