//2.将day19-笔记.txt中的所有行反转(第一行换到最后一行, 第二行换到倒数第二行)
public class Exercise2 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("day19-笔记.txt"));
List<String> list = new ArrayList<String>();
String line;
while((line = br.readLine()) != null)
list.add(line);
br.close();
BufferedWriter w = new BufferedWriter(new FileWriter("invertday19.txt"));
for(int i = list.size() - 1; i >= 0; i--)
w.write(i);
w.close();
}
}
"day19-笔记.txt"是个文档文件 ,通过要求我写了代码 但是编译过后invertday19.txt出现了乱码
检查了10分种 也没看出问题 大哥大姐帮看看
|