1. Method One
try{
Randomaccessfile randomfile = new Randomaccessfile (path, "RW");
Long filelength = Randomfile.length ();
Randomfile.seek (filelength);
String str;
To solve the garbled problem, do the following transformation
byte temp[] = Str.getbytes ();
Randomflie.write (temp);
Randomfile.close;
}catch (Ioexcteption e) {
E.printstacktrace ();
}
2. Method Two
public static void Appendmethodb (string fileName, string content) {
try {
Open a write file, the second parameter in the constructor true indicates that the file is written in append form
FileWriter writer = new FileWriter (FileName, true);
Writer.write (content);
Writer.close ();
} catch (IOException e) {
E.printstacktrace ();
}
}
Add a space to divide a string into several
String StrLine;
Scanner in = new Scanner (system.in);
StrLine = In.nextline ();
String str[] = Strline.split (""); Starting from 0
Append mode file read/write