package com.machuang.io.others; import java.io.BufferedOutputStream; import java.io.DataOutputStream; import java.io.FileOutputStream; import java.io.IOException; public class DataStream { public static void main(String[] args) throws IOException { writeBasicTypes("F:/win10/test/data.txt"); } public static void writeBasicTypes(String desPath) throws IOException { // 要写出的数据 double dataDou = 3.6; long numL = 100L; String dataStr = "architecture"; // 关联写出的文件 DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(desPath)) ); dos.writeDouble(dataDou); dos.writeLong(numL); dos.writeUTF(dataStr); dos.flush(); dos.close(); } }
原文地址:https://www.cnblogs.com/cappuccinom/p/8822956.html
时间: 2024-11-14 02:52:18