Today Plant Science:
/ * 2019.08.19 started to learn, to make this shift. * /
File
Abstract representation of a file or directory
public File(String parent , String child)
Incoming parent directory address, incoming sub-file name
public File(File parent , String child)
Incoming parent directory objects, passing subfolder name
1, the system retrieves the current separator: Properties
public static final String separator
2. Create a new file
public boolean createNewFile() throw IOException
3, delete the current file or directory
public boolean delete()
- If you delete a directory, the directory must be an empty directory
I 流
input: input stream
In the reference memory, an input direction into the memory
For example: the input data from the keyboard into the memory, the read file into a local memory
output: the output stream
Direction from memory is output to the data source, the data derived
1、InputStream
// When a byte of data is read, returns an int data, read to the end, it returns -1
public int read()
// read the data, a data length of the array is read, data is stored in the array, return the length actually read
public int read(byte[ ] b)
2、OutputStream
// write data to the File object, the direct overwrite the original data
FileOutputStream(File file)
// write data to a file path corresponding to the direct overwrite the original data
FileOutputStream(String path)
// Note: when writing data, if the current file does not exist, and complete directory structure, you automatically create a file and write
// write a byte of data to the data source, the current write data lower 8 bits int
void write(int data) throws IOException
// all the data array are all written to the data source
void write(byte[ ] b)
// the data in the array from the next subscript beginIndex, a total length of the length of the table is written to the data source
void write(byte[ ] b , int beginIndex , int length)