public class Example_01 { public static void main(String[] args) { // TODO Auto-generated method stub try { FileOutputStream fs = new FileOutputStream("word.txt"); DataOutputStream ds = new DataOutputStream(fs); ds.writeUTF("使用writeUFT()方法写入数据"); ds.writeChars("使用writeChars()方法写入数据"); ds.writeBytes("使用writeBytes()方法写入数据"); ds.close(); FileInputStream fis = new FileInputStream("word.txt"); DataInputStream dis = new DataInputStream(fis); System.out.println(dis.readUTF()); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
原文地址:https://www.cnblogs.com/dulute/p/10599407.html
时间: 2024-11-12 09:43:01