The read and write operations of TXT text files are often used on the Android platform. The filewriter class of Java virtual machine can be used to process text mime files such as text files on the Android platform. This class is located in Java. Io. filewriter and provides multiple rewriting methods.
Filewriter (File file) // creates a file through a file object
Filewriter (File file, Boolean append) // if the file exists, the second parameter is set to false to overwrite. If it is set to true, it indicates the append method.
Filewriter (filedescriptor FD) // generate a file using the filedescriptor object
Filewriter (string filename) // write the file. The parameter is the complete path and file name.
Filewriter (string filename, Boolean append) // The second parameter is the same as the second overload method.
This class is inherited from Java. Io. outputstreamwriter and has
Void close ()
Void flush ()
String getencoding ()
Void write (char [] Buf, int offset, int count)
Void write (string STR, int offset, int count)
Void write (INT onechar)
You can also use Java. Io. Writer
Writer append (charsequence CSQ)
Writer append (charsequence CSQ, int start, int end)
Writer append (char C)
Abstract void close ()
Abstract void flush ()
Abstract void write (char [] Buf, int offset, int count)
Void write (string STR, int offset, int count)
Void write (INT onechar)
Void write (char [] BUF)
Void write (string Str)
For reading text files on the Android platform, you can use the filereader class, which is located in Java. io. filereader provides three rewrite Methods: filereader (File file), filereader (filedescriptor FD), and filereader (string filename). The only thing you need to note is that the filenotfoundexception exception is thrown. You can use the following methods for reading the parent class:
All methods of Java. Io. inputstreamreader are supported.
Void close ()
String getencoding ()
Int read (char [] Buf, int offset, int length)
Int read ()
Boolean ready ()
Supports all java. Io. Reader methods.
Abstract void close ()
Void mark (INT readlimit) // sets a flag
Boolean marksupported () // determines whether the mark () or reset () method is supported
Abstract int read (char [] Buf, int offset, int count)
Int read (charbuffer target)
Int read (char [] BUF)
Int read ()
Boolean ready ()
Void reset () // reset the read location
Long SKIP (Long Count)