#####locad.txt F0:名称:HANGYUE/ICONS/YUE.JPG:START .//help.txt F1:我要把你写掉 F2:名称:HANGYUE/ICONS/YUE.JPG:START .//help.txt #####程序:import java.io.*; public class Wtext{ public static void main(String[] args) { Wtext text = new Wtext(); text.Wtxt("F1","我要把你写掉"); }
F0:名称:HANGYUE/ICONS/YUE.JPG:START .//help.txt
F1:我要把你写掉
F2:名称:HANGYUE/ICONS/YUE.JPG:START .//help.txt
#####程序:import java.io.*;
public class Wtext{
public static void main(String[] args)
{
Wtext text = new Wtext();
text.Wtxt("F1","我要把你写掉");
}
private void Wtxt(String getH,String getM){
try{
String line="";
FileReader file_reader;
file_reader=new FileReader ("locad.txt");
BufferedReader in=new BufferedReader (file_reader);
StringBuffer sb=new StringBuffer();
int pos=0;
while((line=in.readLine())!=null){
System.out.println (line);
if(line.startsWith(getH)){
pos=line.indexOf(":");
line=line.substring(0,pos+1);
line=line+getM;
System.out.println (line);
}
sb.append(line+"\r\n");
}
file_reader.close ();
FileWriter file_writer;
file_writer=new FileWriter ("locad.txt");
PrintWriter pw=new PrintWriter(file_writer);
pw.print(sb.toString());
file_writer.close();
}
catch(FileNotFoundException e1){}
catch (IOException e2){}
}
}