public class StringIoTool {
public static String read(String filename) throws IOException{
Reader reader=new FileReader(filename);
BufferedReader bf=new BufferedReader(reader);
StringBuilder sb=new StringBuilder();
String str;
do {
str =bf.readLine();
if(str!=null)
sb.append(str+"\n");
}while(str!=null);
bf.close();
reader.close();
return sb.toString();
}
public static void write(String filename,String content) throws IOException {
Writer writer=new FileWriter(filename);
writer.write(content);
writer.close();
}
public static void main(String[] args) throws IOException {
String str=StringIoTool.read(“d:\file2.txt”);
StringIoTool.write(“d:\file.txt”,str);
}
}