写入文件 File file = new File("word.txt");try {FileWriter out = new FileWriter(file); String s = jTextArea.getText();out.write(s); // 将信息写入磁盘文件out.close(); // 将流关闭 } catch (Exception e1) {e1.printStackTrace();}
File file = new File("word.txt"); try { FileWriter out = new FileWriter(file); String s = jTextArea.getText(); out.write(s); // 将信息写入磁盘文件 out.close(); // 将流关闭 } catch (Exception e1) { e1.printStackTrace(); }文件读取
File file = new File("word.txt"); // 创建文件对象 try { FileReader in = new FileReader(file); char byt[] = new char[1024]; // 创建char型数组 int len = in.read(byt); // 将字节读入数组 jTextArea.setText(new String(byt, 0, len)); in.close(); // 关闭流 } catch (Exception e1) { e1.printStackTrace(); }