原文本文件如下:
Name: CVE-1999-0002
Status: Entry
Reference: SGI:19981006-01-I
Reference: URL:ftp://patches.sgi.com/support/free/security/advisories/19981006-01-I
Reference: CERT:CA-98.12.mountd
Reference: CIAC:J-006
Reference: URL:http://www.ciac.org/ciac/bulletins/j-006.shtml
Reference: BID:121
Reference: URL:http://www.securityfocus.com/bid/121
Reference: XF:linux-mountd-boBuffer overflow in NFS mountd gives root access to remote attackers,
mostly in Linux systems.======================================================
Name: CVE-1999-0003
Status: Entry
Reference: NAI:NAI-29
Reference: CERT:CA-98.11.tooltalk
Reference: SGI:19981101-01-A
Reference: URL:ftp://patches.sgi.com/support/free/security/advisories/19981101-01-A
Reference: SGI:19981101-01-PX
Reference: URL:ftp://patches.sgi.com/support/free/security/advisories/19981101-01-PX
Reference: XF:aix-ttdbserver
Reference: XF:tooltalk
Reference: BID:122
Reference: URL:http://www.securityfocus.com/bid/122Execute commands as root via buffer overflow in Tooltalk database
server (rpc.ttdbserverd).======================================================
Name: CVE-1999-0004
Status: Candidate
URL: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-0004
Phase: Modified (19990621-01)
Category: SF
Reference: CERT:CA-98.10.mime_buffer_overflows
Reference: XF:outlook-long-name
Reference: SUN:00175
Reference: MS:MS98-008
Reference: URL:http://www.microsoft.com/technet/security/bulletin/ms98-008.aspMIME buffer overflow in email clients, e.g. Solaris mailtool
and Outlook.
Current Votes:
   ACCEPT(8) Magdych, Northcutt, Wall, Baker, Landfield, Cole, Dik, Collins
   MODIFY(1) Frech
   NOOP(1) Christey
   REVIEWING(1) ShostackVoter Comments:
 Frech> Extremely minor, but I believe e-mail is the correct term. (If you reject
   this suggestion, I will not be devastated.) :-)
 Christey> This issue seems to have been rediscovered in
   BUGTRAQ:20000515 Eudora Pro & Outlook Overflow - too long filenames again
   http://marc.theaimsgroup.com/?l=bugtraq&m=95842482413076&w=2
   
   Also see
   BUGTRAQ:19990320 Eudora Attachment Buffer Overflow
   http://marc.theaimsgroup.com/?l=bugtraq&m=92195396912110&w=2
 Christey> 
   CVE-2000-0415 may be a later rediscovery of this problem
   for Outlook.
 Dik> Sun bug 4163471,
 Christey> ADDREF BID:125
 Christey> BUGTRAQ:19980730 Long Filenames & Lotus Products
   URL:http://marc.theaimsgroup.com/?l=bugtraq&m=90221104526201&w=2
======================================================
Name: CVE-1999-0005
Status: Entry
Reference: CERT:CA-98.09.imapd
Reference: SUN:00177
Reference: URL:http://sunsolve.sun.com/pub-cgi/retrieve.pl?doctype=coll&doc=secbull/177
Reference: BID:130
Reference: URL:http://www.securityfocus.com/bid/130
Reference: XF:imap-authenticate-boArbitrary command execution via IMAP buffer overflow in authenticate
command.上面只是文件的某部分记录,还有很多差不多的记录,连等号之间就是一条记录,现在想把每行冒号那个东西去掉,然后其余的规则的导入到另外一个文件中,每行之间用逗号隔开(前面相同标记的为一项,如reference项,但行内容用"."隔开,reference行下面的所有内容为一项),每条记录用回车隔开:例如第一条记录导入应如下:
CVE-1999-0002,Entry,SGI:19981006-01-I.URL:ftp://patches.sgi.com/support/free/security/advisories/19981006-01-I.CERT:CA-98.12.mountd.CIAC:J-006.URL:http://www.ciac.org/ciac/bulletins/j-006.shtml.BID:121.URL:http://www.securityfocus.com/bid/121.XF:linux-mountd-bo,Buffer overflow in NFS mountd gives root access to remote attackers,
mostly in Linux systems.

解决方案 »

  1.   

    有些记录的内容不是一致的,如有些有URL这项,有些则没有,我是希望把每行第一个冒号之后的内容都写到另外一个文件里去,但我只会下面这个全部COPY的算法,不知道大家可不可以帮忙改下:
    import java.io.*;public class ReadWriteFile{
     public static void main(String[] args){
      try{
       
       File read = new File("d:\\1.txt");
       File write = new File("d:\\2.txt");
       
       BufferedReader br = new BufferedReader(
             new FileReader(read));
       BufferedWriter bw = new BufferedWriter(
             new FileWriter(write));
       String temp = null;
       temp = br.readLine();
       while(temp != null){
        //写文件
        bw.write(temp + "\r\n"); 
        //继续读文件
        temp = br.readLine();
       }
       
       bw.close();
       br.close();
       
      }catch(FileNotFoundException e){
       System.out.println (e);
      }catch(IOException e){
       System.out.println (e);
      } 
     } 
    }
      

  2.   

    Name: CVE-1999-0004 
    Status: Candidate 
    URL: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-0004 
    Phase: Modified (19990621-01) 
    Category: SF 
    Reference: CERT:CA-98.10.mime_buffer_overflows 
    Reference: XF:outlook-long-name 
    Reference: SUN:00175 这种URL:也不留?还有这种 Current Votes: 要留不?
    Current Votes: 
       ACCEPT(8) Magdych, Northcutt, Wall, Baker, Landfield, Cole, Dik, Collins 
       MODIFY(1) Frech 
       NOOP(1) Christey 
       REVIEWING(1) Shostack 还是只是把Name: Status:  Reference:这3个开头的去掉你用第一个记录作例子太不通用了 没法完全理解要求
      

  3.   

    例如:有这么一个例子Name: 1
    Status:2  
    URL:3
    Phase: 4  
    Category:5 
    Reference:6 
    Reference: 7
    Reference: 8
    ..这里是回车..
    a
    b
    ====================================================== Name: 11
    Status:22 
    Phase: 44
    Category:55 
    Reference:66 
    Reference: 77
    Reference:88
    ..这里是回车..
    c
    d
    ~~~~~~~~~~
    那么导入文本文件的格式应该这样:
    1,2,3,4,5,6.7.8,a.b
    11,22,null,44,55.66.77,88,c.d就是把每行第一个冒号之前的内容去掉,但最后Reference之后的内容(上面的红色回车之后的内容)全部保留
    有一些字段不是每条记录都有的,没有的就用NUll代替,如上面例子的URL