package com.heima.test;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
public class Test1 {
/**
* * 将一个文本文档上的文本反转,第一行和倒数第一行交换,第二行和倒数第二行交换
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("zzz.txt"));
ArrayList<String> al = new ArrayList<>();
String line;
while((line = br.readLine()) != null) {
al.add(line);
}
for (int i = al.size() - 1; i >= 0; i--) {
System.out.println(al.get(i));
}
}
}
|
|