import java.io.*;
public class ReadWriteText {
public static void main(String[] args) throws IOException {
String s = "";
StringBuffer str = new StringBuffer();
FileReader FReader = new FileReader( "Text.txt");
BufferedReader BR = new BufferedReader(FReader);
while ((s = BR.readLine())!= null){
str.append(s);
str.append( "\n");
}
BR.close();
System.out.println(str);
FileWriter FWriter = new FileWriter( "MyWriter.txt");
PrintWriter Pwriter = new PrintWriter(FWriter);
Pwriter.print( "My first print!");
Pwriter.close();
}
}
public class ReadWriteText {
public static void main(String[] args) throws IOException {
String s = "";
StringBuffer str = new StringBuffer();
FileReader FReader = new FileReader( "Text.txt");
BufferedReader BR = new BufferedReader(FReader);
while ((s = BR.readLine())!= null){
str.append(s);
str.append( "\n");
}
BR.close();
System.out.println(str);
FileWriter FWriter = new FileWriter( "MyWriter.txt");
PrintWriter Pwriter = new PrintWriter(FWriter);
Pwriter.print( "My first print!");
Pwriter.close();
}
}
转载于:https://blog.51cto.com/sophi/66375