BufferedReader br =
new
BufferedReader(
new
FileReader(
"D:\\1.txt"
));
BufferedWriter bw =
new
BufferedWriter(
new
FileWriter(
"D:\\1.txt"
));
String temp =
null
;
while
((temp = br.readLine())!=
null
)
{
String index = temp.replaceAll(
"^(.*)\\d{4}-\\d+-\\d+"
,
"$1"
);
bw.write(index +
"\r\n"
);
}
package MyTest;
import java.io.*;
import java.util.LinkedList;
import java.util.ListIterator;
/**
*
* @author Administrator
*/
public class Test22 {
public static void main(String args[]) throws FileNotFoundException, IOException { //FileReader fr = new FileReader("D:/我的文档/NetBeansProjects/IT/src/MyTest/c.txt"); FileInputStream fr=new FileInputStream("D:/我的文档/NetBeansProjects/IT/src/MyTest/b.txt"); InputStreamReader is=new InputStreamReader(fr,"GB2312"); BufferedReader br = new BufferedReader(is); LinkedList ll = new LinkedList(); String s; while ((s = br.readLine()) != null) { ll.addFirst(s); } br.close(); ListIterator li = ll.listIterator(ll.size()); while (li.hasPrevious()) { System.out.println(li.previous()); } }}