JAVA如何實現從最後一行讀取文件
import java
import java
import java
public class FromEndRF {
public static void read(String filename) {
read(filename
}
public static void read(String filename
RandomAccessFile rf = null;
try {
rf = new RandomAccessFile(filename
long len = rf
long start = rf
long nextend = start + len
String line;
rf
int c =
while (nextend > start) {
c = rf
if (c ==
line = rf
if (line != null) {
System
}else {
System
}
nextend
}
nextend
rf
if (nextend ==
System
}
}
} catch (FileNotFoundException e) {
e
} catch (IOException e) {
e
} finally {
try {
if (rf != null)
rf
} catch (IOException e) {
e
}
}
}
public static void main(String args[]) {
read(
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26379.html