When deciding whether a file object is a file or a directory, it is necessary to judge whether the contents of the file object are encapsulated, to judge by the exists, and to specify the encoding mode when the text file is constructed in the operation stream.
File F;
F.exists ();
F.isdirectory ();
F.isfile ();
F.deleteonexit ();//delete the specified file when the program exits;
F.createnewfile ()//creates a file at the specified location and returns False if the file already exists;
F.getparent ()//This method returns the parent directory in the absolute path, returns null if a relative path is obtained, and returns the directory if there is a previous level in the relative path;
File.separator//File system separator, different system separator;
filenamefilter://for filtering file names;
Filenamefilter.accept (File dir,string name); Tests whether the specified file is contained in a list of files;
Name: Names of files;
Public Boolean Accept (File dir, String name) {return Name.endswith (". txt"); }
The emergence of the buffer is to improve the operation efficiency of the flow, and before the buffer is created, there must be a stream object;
Buffer technology is in fact, in the object to close the array, save a one-time write;
Constructor: The constructor that will circulate into the buffer;
Notice: As long as the buffer is used, the buffer must be refreshed;
Buffered. buf;
Buf.flush ();
Buf.close ();//close buffer is the stream object in the closed buffer;
BufferedReader Bufr;
Bufr.readline ()//returns a row, but does not contain line breaks;
Whether you read one line or more characters, you end up reading one at a time on your hard disk, so the method you end up using the Read method reads a
/*
* Bytearrayinputstream: At the time of construction, need to receive the data source, and the data source is a byte array;
* Bytearrayoutputstream: In construction, do not define the purpose of the data, because the internal definition of a variable-length byte array, it is the data destination;
* Two stream objects are operating arrays, and do not use system resources, do not need to be closed operation;
*/
The data in the internal buffer is refreshed before the flow resource is closed;
Flush (); Refresh (the data in the buffer into the file), the stream continues to use;
Serialization: Static members cannot be serialized;
If you do not want non-static members to be serialized, add modifiers: transient int,,,
System.in:InputStream
System.out:OutputStream