When determining whether a file object is a file or directory, you must first determine whether the content encapsulated by the file object exists, and judge by exists; the encoding method can also be specified when constructing the text file operation stream;
File f;
f.exists();
f.isDirectory();
f.isFile();
f.deleteOnExit();//Delete the specified file when the program exits;
f.createNewFile();//Create a file at the specified location. If the file already exists, return false;
f.getParent();//This method returns the parent directory in the absolute path. If the relative path is obtained, Null is returned. If there is an upper-level directory in the relative path, the directory is returned;
File.separator //File system separator, different systems have different separators;
FilenameFilter:// is used to filter file names;
FilenameFilter.accept(File dir,String name); //Test whether the specified file is included in a file list;
name: the name of the file;
public boolean accept(File dir, String name) { return name.endsWith(".txt"); }
//The buffer appears to improve the efficiency of stream operations; before creating a buffer, there must be a stream object;
//Buffering technology actually closes the array inside the object, and writes it once after saving;
Constructor: The constructor that passes the stream into the buffer;
Notice: As long as the buffer is used, the buffer must be refreshed;
Buffered... buf;
buf.flush();
buf.close();//Close the buffer is to close the stream object in the buffer;
BufferedReader bufr;
bufr.readLine();//Returns a line, but does not contain a newline character;
// Whether reading one line or multiple characters, in fact, they are read one by one on the hard disk, so the final method used is to read one at a time using the read method.
/*
* ByteArrayInputStream: During construction, the data source needs to be received, and the data source is a byte array;
* ByteArrayOutputStream: When constructing, there is no need to define the data destination, because a variable-length byte array is defined internally, which is the data destination;
* Both stream objects operate on arrays, do not use system resources, and do not need to be closed;
*/
//The data in the internal buffer will be refreshed before closing the stream resource;
// flush(); After refreshing (storing the data in the buffer to the file), the stream continues to be used;
// Serialization: Static members cannot be serialized;
// If you don't want non-static members to be serialized, add modifier: transient int,,,
System.in:InputStream
System.out:OutputStream