比如我的文本里有这些数据  11=1`1`1` 
22=2`2`2` 
33=3`33333`3` 
n=3 
我想删除22=2`2`2`怎么在代码中实现···那个RERomve好像不行

解决方案 »

  1.   


    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class PropertyTest{
       public static void main(String rags[])throws Exception{
           URL url=PropertyTest.class.getResource("1.properties") ;
       String path=URLDecoder.decode(url.getFile(),"UTF-8");
           File f=new File(path);
       Properties props=new Properties();
       FileInputStream fis=new FileInputStream(path);   
       props.load(fis);
       fis.close();
       props.remove("password");
       FileOutputStream fos=new FileOutputStream(path);
           props.store(fos,"");
           fos.close();
       }
    }1.properties和PropertyTest.java放在同一个目录下,里面的初始内容是:
    username=aaa
    password=aaa
    运行程序可以把password=aaa删掉