日期:2014-05-20 浏览次数:20791 次
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.*; public class test { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new FileReader("d:\\menu.txt")); String s; String str2 = ""; String strNum = ""; while ((s = br.readLine()) != null) { String s2[] = s.split(" "); if(s2[1] != null){ str2 = s2[1]; } String s3[] = str2.split("元"); if(s3[1] != null){ strNum = strNum + s3[0]; } /* 保存五个数据 */ } System.out.println("result:"+strNum); br.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e2) { e2.printStackTrace(); } } }