根据给定输入文件中的字符串创建文件夹和文本文件

时间:2016-06-17 09:58:00

标签: java substr

我有一个40K +行的文件。每行的格式如下。

......一些随机文本..... OWN AB ..... XML ....... XML .... ...一些随机文本..... OWN MN ..... XML ....... XML .... ...一些随机文本..... OWN XY ..... XML ....... XML .... ......一些随机文本..... OWN AB ..... XML ....... XML ....

我想创建一个文件夹,其中包含 OWN 以及内容为XM的文本文件... XML

可以有许多具有相同OWN代码的行。因此,应在现有文件夹中创建下一个文件。

你能用Java帮忙吗? 谢谢。

while((strLine = br.readLine())!= null){

      // Print the content on the console
      System.out.println (strLine);   
      String Filename = "D:/Result/TestCase";
      Filename = Filename + "_"+ count + ".txt";
      try(  PrintWriter out = new PrintWriter( Filename )  )
        {
            out.println( strLine );
            count++;

        }


    }

0 个答案:

没有答案