并且最好用JDK1.5来编译运行程序,首先它的界面比1.4的好看多了
现在JDK1.6都出来了,JDK1.5也出来两年多了....
可惜不是你,陪我到最后
import java.io.*;
import java.util.regex.*;
public class IOtest
{
public static void main(String[] args) throws Exception
{
String str;
BufferedWriter bw1=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("2.txt")));
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream("1.txt")));
while((str=br.readLine()) !=null)
{
int sum=0;
Matcher m=Pattern.compile("\\d{2}",Pattern.MULTILINE).matcher(str);
while(m.find())
{
sum=sum+Integer.parseInt(m.group());
}
String st=str.replaceAll("#\\d{2}.+","#"+sum);
bw1.write(st,0,st.length());
bw1.newLine();
}
bw1.close();
}
}
这样你看行不行?