获取每行拆分字符串的内容

时间:2013-06-30 13:14:30

标签: java io split fileinputstream

所以我有这个文件:

    ------------splitter------------ 
classname: test
class: testing
description: this is a test
------------splitter------------ 
classname: test1
class: testing1
description: this is a test1
------------splitter------------ 
classname: test2
class: testing2
description: this is a test2

我正在阅读以下文件:

try {
            final FileInputStream fis = new FileInputStream("class.file");
            BufferedReader b = new BufferedReader(new InputStreamReader(fis));
            String line;
            while ((line = b.readLine()) != null) {
                String[] split = line.split("------------splitter------------");
   }
        }  catch (Exception e) {
        }

我如何获得所有行的内容,类名,类和描述?我尝试过split [0],只返回整个代码(没有--- splitter ---)。

0 个答案:

没有答案