Fileinputstream and fileoutputstream
Fileinputstream:
It is used to access local files in sequence and read original byte streams such as data. It inherits methods such as read and close from the super-class inputstream, and does not support methods and methods. its two common constructor methods are:
Fileinputstream (string filepath/* full file path */);
Fileinputstream (File fileobj/* file object describing the file */);
You can use this method to construct the file input stream:
(1) fileinputstream F1 = new fileinputstream("test.txt & quot ;);
(2) file F = new file("test.txt & quot ;);
Fileinputstream & nbsp; F2 = new fileinputstream (f );
Fileinputstream overrides the Data Reading method of the abstract class inputstream:
Public int read // read a Data byte from the input stream
Public int read (byte [] B); // read data of up to B bytes from the input stream into a byte array
Public int read (byte [] B, int off, int Len); // reads data of up to len bytes into the byte array from the input stream
If the input stream ends when data is read,-1 is returned.
Fileoutputstream:
Fileoutputstream is used to write data to a text file. It is used to write the streams of raw bytes such as data. It inherits from the superclass outputstream and other methods. Its common construction methods are as follows:
Fileoutputstream (string filepath/* full file path */)
Fileoutputstream (File fileobj/* object describing the file */)
Fileoutputstream (string filepath, Boolean append/* if it is true, the file is opened in append mode without overwriting the content of the existing file. If it is false, it overwrites the content of the original file */)
Fileoutputstream (File fileobj, Boolean append)
The creation of fileoutputstream does not depend on whether the file exists. If the file indicated by filepath does not exist, fileoutputstream will be created before it is opened. If the file exists, open it and prepare to write content. If a read-only file is opened, an ioexception is thrown.