请教java处理txt文本文件

3 10 11 21 30 34 36 40 41 53 58 64 68 76 85 87 91 94 101 104 116 123

3 10 20 21 23 34 36 39 41 53 56 64 68 76 85 87 91 94 101 105 115 119

1 10 19 21 24 34 36 39 42 53 56 64 68 76 85 87 91 94 101 105 115 121

3 9 19 21 30 34 36 40 42 53 58 64 68 76 85 87 91 94 101 104 116 123

3 10 14 22 29 34 37 39 41 54 58 64 68 76 85 87 91 94 97 105 113 119

3 9 20 21 23 34 36 39 42 53 56 64 68 76 85 87 91 94 101 104 115 119

1 10 19 21 23 34 36 39 45 53 56 64 68 76 85 87 91 94 101 104 115 121

上面是要处理的txt文件

谁能告诉我怎么编写个程序实现查找统计

就是按列来分析

比方第一列,3的个数是5,1的个数是2,然后再第二列10的个数是5……

然后输出每个数及其个数?

谢谢

[code="java"]
try {

        File file = new File("D:/work/eclipse_workspace/TST/src/l.txt");
        FileReader reader = new FileReader(file);
        BufferedReader in = new BufferedReader(reader);
        String currentLine = "";
        StringBuffer strBuffer = new StringBuffer(1000);
        while ((currentLine = in.readLine()) != null) {
            strBuffer.append(currentLine);
            strBuffer.append("@");
        }

        String[] strTemp = (strBuffer.toString()).split("@");
        if (strTemp.length > 0) {
            int numberCount = strTemp[0].split(" ").length;
            String[][] strResult = new String[strTemp.length][numberCount];
            for (int i = 0; i < strTemp.length; ++i) {
                strResult[i] = strTemp[i].split(" ");
            }

            for (int j = 0; j < numberCount; j++) {
                TreeMap<String, Integer> numbersMap = new TreeMap<String, Integer>();
                for (int i = 0; i < strResult.length; i++) {

                    if (numbersMap.containsKey(strResult[i][j])) {
                        int count = (Integer) numbersMap
                                .get(strResult[i][j]);
                        numbersMap.put(strResult[i][j], count + 1);
                    } else {
                        numbersMap.put(strResult[i][j], 1);
                    }
                }
                Iterator it =numbersMap.keySet().iterator(); 
                while (it.hasNext()) {
                    String key = (String) it.next();
                    System.out.println(key + "的数量是:" + numbersMap.get(key));
                }
                System.out.println("\n");
            }       

            in.close();
            reader.close();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

[/code]
1的数量是:2

3的数量是:5

10的数量是:5

9的数量是:2

......

按行为单位,再以空格切分,保存为二维数组.?

try {
int nLineCount = 0;//行数
File file = new File("xxx.txt");
BufferedReader in = new BufferedReader(new FileReader(file));
String strLine = "";
StringBuffer strBuffer = new StringBuffer(1000);
while ((strLine = in.readLine()) != null) {
strBuffer.append(strLine);
strBuffer.append("^^");
++nLineCount;
}
//最终结果保存在strResult中,第一行在strResult[0],第一行第一列在strResult[0][0]
String[][] strResult = new String[nLineCount][];
String[] strTemp = (strBuffer.toString()).split("^^");
for (int i = 0; i < strTemp.length; ++i) {
for (int j = 0; j < strTemp.length(); ++j) {
strResult = strTemp.split(" ");
}
}
//下面遍历二位数组输出每个数的个数就可以了,这个你肯定会了。加油!
} catch (Exception e) {
e.printStackTrace();
}

用JAVA进行批量数据计算比较复杂,用集算器简单很多:

A1=file("E:\s.txt").import(;" ")
A2=A1.fno().(A1.field(~).groups(~:no;count(~):count))
A3=A2.conj(~.new(A2.#:列,no:数字,count:个数))