java读写txt import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;public class Text {public void JavaToText(String text) {FileWriter fw = null;BufferedWr
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Text { public void JavaToText(String text) { FileWriter fw = null; BufferedWriter bw = null; try { fw = new FileWriter("/home/text.txt"); bw = new BufferedWriter(fw); bw.write(text); bw.close(); fw.close(); } catch (IOException e) { e.printStackTrace(); } } public String TextToJava() { FileReader fr = null; BufferedReader br = null; String text = null; try { fr = new FileReader("/home/text.txt"); br = new BufferedReader(fr); text = br.readLine(); br.close(); fr.close(); } catch (Exception e) { e.printStackTrace(); } return text; }