如何从java中的文本文件中删除特定行

时间:2013-10-31 09:23:36

标签: java

我需要删除或删除此文件的前6行(以下是我的输入文件)并将其余内容写入单独的文本文件中?我该怎么做....

[S:00]
{org:en}
I called the number and the lady told me she was talking on the phone to Toby Studabaker,'' Sherry Studabaker told BBC television.

{/org}
{unl}
agt(call(icl>do,equ>dial,plt>thing,plf>thing,agt>volitional_thing,rec>thing).@entry.@past,i(icl>person):01)
and(:01,call(icl>do,equ>dial,plt>thing,plf>thing,agt>volitional_thing,rec>thing).@entry.@past)
rec(call(icl>do,equ>dial,plt>thing,plf>thing,agt>volitional_thing,rec>thing).@entry.@past,number(icl>abstract_thing,icl>quantity,obj>thing).@def)
agt:01(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):01.@entry.@past,lady(icl>woman>person).@def)
rec:01(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):01.@entry.@past,i(icl>person):02)
agt:02(talk(icl>communicate>do,cob>uw,agt>person,obj>thing,ptn>person).@entry.@past.@progress,she(icl>person))
cob:02(talk(icl>communicate>do,cob>uw,agt>person,obj>thing,ptn>person).@entry.@past.@progress,phone(icl>electronic_equipment>thing,equ>telephone).@def)
ptn:02(talk(icl>communicate>do,cob>uw,agt>person,obj>thing,ptn>person).@entry.@past.@progress,toby)
nam:02(toby,studabaker:01)
agt:03(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):02.@past,sherry(icl>fortified_wine>thing).@maiuscul)
nam:03(sherry(icl>fortified_wine>thing).@maiuscul,studabaker:02)
rec:03(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):02.@past,bbc(iof>organization))
obj:03(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):02.@past,television(icl>broadcasting>thing))
and(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):02.@past,:02)
obj:01(tell(icl>say>do,cob>uw,agt>person,obj>uw,rec>person):01.@entry.@past,:03)
{/unl}

1 个答案:

答案 0 :(得分:1)

你是怎么做到的?

  open input file
  open output file
  repeat:
      read line
      is line number greater than 6?
         write line
  until EOF
  close files

现在用Java编写代码。


在Java中没有聪明的方法可以做到这一点,我不知道任何第三方库会大大简化这个(已经非常简单)的问题。