Best way to extract specific paragraph from file data

后端 未结 2 565
予麋鹿
予麋鹿 2021-01-21 18:15

Hi i am looking to find out the best way to extract specific paragraph from file using java.

From the following data i need to extract data from \"D & A\"

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-21 18:53

    I would read in the file line by line, something like this tutorial.

    You can then check if the line contains a certain string.

    boolean readFollowingLines = false;
    ArayList paragraph=new ArayList();
    if( string.indexOf("1- End") > 0 ) // maybe >= 0, not shure
        readFollowingLines = false;
    if (readFollowingLines)
       paragraph.add(string);
    if( string.indexOf("D and A") > 0 ) // maybe >= 0, not shure
       readFollowingLines = true;
    

    If you want more then one paragraph you need to extend this a little. Anyway, I'd probably do it something like this

提交回复
热议问题