Package Comz;
Import java.io.FileNotFoundException;
Import java.io.IOException;
Import Java.io.RandomAccessFile;
public class FROMENDRF {public static void read (String filename) {read (filename, "GBK");
public static void Read (string filename, string charset) {Randomaccessfile RF = null;
try {rf = new Randomaccessfile (filename, "R");
Long len = Rf.length ();
Long start = Rf.getfilepointer ();
Long NextEnd = start + len-1;
String Line;
Rf.seek (NextEnd);
int c =-1;
while (NextEnd > Start) {c = Rf.read ();
if (c = = ' \ n ' | | c = = ' \ r ') {line = Rf.readline ();
if (line!= null) {System.out.println (the new String (line. GetBytes ("Iso-8859-1"), CharSet));
else {System.out.println (line);
} nextend--;
} nextend--;
Rf.seek (NextEnd);
if (NextEnd = = 0) {//When the file pointer is back to the beginning of the file, the output first line = Rf.readline (); System.out.println (New String (Line.getbytes ("iso-8859-1"), CharSet));
A catch (FileNotFoundException e) {e.printstacktrace ());
catch (IOException e) {e.printstacktrace ();
Finally {try {if (RF!= null) rf.close ();
catch (IOException e) {e.printstacktrace ();
}} public static void Main (String args[]) {Read ("D:\\2.txt", "GBK"); }
}
Borrowed the code of old Zi Zhu.