1. Create TXT file
Just write according to normal logic.
First define a file given a path--to determine if the file does not exist on this path--and if it doesn't exist, it will be created automatically based on the program prompts. Try/catch
2. Read TXT file
Idea 1:
Get a file path
Create a new file with this path to determine if the file exists in a normal file format.
Create a reading buffer with this path: Fileinputstream-->inputstreamreader-->bufferedreader
Row by line to determine whether the content is empty, to accumulate the read result on a string (result)
Releasing buffer resources
Idea 2
Similar to the idea 1, just the buffer reader is constructed in a different way, see the Red Line section, Filereader-->bufferedreader
3. Write TXT file
Idea 1:
To write a file, you need to first determine if the file exists, and if it does not exist, create a
Write to the content using the methods in the FileWriter class, control the Write form with the append parameter, append write when Append is true, overwrite write when Append is False
Close File
Idea 2
Make the following adjustments to the above code, i.e. using BufferedWriter
Java read txt file, new txt file, write TXT file