java解析TXT,读取本地的txt并且解析

txt中有这样一串字符4000:1|ZSTAT:1|FSTAT:1,读取这三个冒号后面的1并且存在数组里
能给写出这样的代码方便学习,本人小白。

http://www.cnblogs.com/manongxiaojiang/archive/2012/10/13/2722068.html

从文本里面读取数据然后解析。。有没有大神帮个忙

借用人类新纪元开始了

try {
        int dataSorce[]=new int[3];
        String encoding="GBK";
        File file=new File("C:\\Users\\Administrator\\Desktop\\a.txt");
        if(file.isFile() && file.exists()){ //判断文件是否存在
            InputStreamReader read = new InputStreamReader(
            new FileInputStream(file),encoding);//考虑到编码格式
            BufferedReader bufferedReader = new BufferedReader(read);
            String lineTxt = null;
            while((lineTxt = bufferedReader.readLine()) != null){
                //取出来之后就是字符串,流的作用是把硬盘里的数据给读到内存里来,然后程序就能操作这些数据
                            String splitArray[] = lineTxt.split(":");   
                            //[4000, 1|ZSTAT, 1|FSTAT, 1]分开之后的值
                            for(int i=1;i<splitArray.length-1;i++){
                                //splitArray[i].charAt(0)是字符1,字符1的编码是49
                                //也就是字符1和数字1相差48
                                dataSorce[i-1] = (int)splitArray[i].charAt(0)-48;
                            }
                            dataSorce[2] = Integer.parseInt(splitArray[splitArray.length-1]);
                System.out.println(Arrays.toString(dataSorce));
                System.out.println(Arrays.toString(splitArray));
            }
            read.close();
}else{
    System.out.println("找不到指定的文件");
}
} catch (Exception e) {
    System.out.println("读取文件内容出错");
    e.printStackTrace();
}