import java.io.IOException;
import java.io.RandomAccessFile;
/**
* (十) 使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
*/
class IO10 {
public static void main(String[] args) throws IOException {
RandomAccessFile raf = new RandomAccessFile("异常日志.txt", "r");
String str = null;
StringBuilder sb = new StringBuilder();
while ((str = raf.readLine()) != null) {
sb.append(str);
sb.append("\n");
}
raf.close();
System.out.println(sb.reverse());
}
}
使用随机文件流类RandomAccessFile将一个文本文件倒置读出。
最新推荐文章于 2023-05-07 20:24:59 发布