当前位置: 技术问答>java相关
必给高分求救:怎样用JAVA实现在文本文件中搜索一个字符串?详情见内!
来源: 互联网 发布时间:2015-01-01
本文导语: 例如:我想在www.txt中有一段语句如下: sss=www,rrr,fff 我想用JAVA写语句搜索到SSS=,然后再后面添加为: sss=www,rrr,fff,ddd !请高手指教!:) | something like: // create and load properties Properties appl...
例如:我想在www.txt中有一段语句如下:
sss=www,rrr,fff
我想用JAVA写语句搜索到SSS=,然后再后面添加为:
sss=www,rrr,fff,ddd
!请高手指教!:)
sss=www,rrr,fff
我想用JAVA写语句搜索到SSS=,然后再后面添加为:
sss=www,rrr,fff,ddd
!请高手指教!:)
|
something like:
// create and load properties
Properties applicationProps = new Properties();
FileInputStream in = new FileInputStream("www.txt");
applicationProps.load(in);
in.close();
String lName = "sss";
String lValue = (String) applicationProps.getProperty(lName);
applicationProps.put(lName, lValue+",ddd");
//store the modify
FileOutputStream out = new FileOutputStream("www.txt");
applicationProps.store(out, "---No Comment---");
out.close();
// create and load properties
Properties applicationProps = new Properties();
FileInputStream in = new FileInputStream("www.txt");
applicationProps.load(in);
in.close();
String lName = "sss";
String lValue = (String) applicationProps.getProperty(lName);
applicationProps.put(lName, lValue+",ddd");
//store the modify
FileOutputStream out = new FileOutputStream("www.txt");
applicationProps.store(out, "---No Comment---");
out.close();