Java案例:统计文本中所有整数之和

xiaoxiao2021-02-28  43

一、源代码

/** * 功能:统计文件中的数字之和 * 作者:华卫 * 日期:2013年7月20日 */ package regex; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CountNumbers { public static void main(String[] args) { int sum = 0; try { FileReader fr = new FileReader("src/regex/译诗录.txt"); BufferedReader br = new BufferedReader(fr); StringBuffer buffer = new StringBuffer(); String strNextLine = ""; strNextLine = br.readLine(); while (strNextLine != null) { buffer.append(strNextLine "\n"); strNextLine =
转载请注明原文地址: https://www.6miu.com/read-2628158.html

最新回复(0)