import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.LinkedList;
public class A {
/**
* @param args
*/
public static void main(String[] args) {
File file = new File("c:/a.txt");
LinkedList
if (file.exists() && file.isFile()) {
try{
BufferedReader input = new BufferedReader(new FileReader(file));
String text;
while((text = input.readLine()) != null)
list.add(text);
}
catch(IOException ioException){
System.err.println("File Error!");
}
}
for (int i = list.size() - 1; i >= 0; i--) {
System.out.println(list.get(i));
}
File out = new File("c:/b.txt");
if (out.exists()) {
out.delete();
}
try {
if (out.createNewFile()) {
BufferedWriter output = new BufferedWriter(new FileWriter(out));
for (int i = 0; i < list.size(); i++) {
output.write((i + 1) + " " + list.get(i) + "\r\n");
}
output.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
额 这个题不难吧。。
就是读文件吗,明天给你代码。