日期:2014-05-20 浏览次数:20745 次
import java.io.*; public class DataOutputStreamDemo { public static void main(String[] args) { File file=new File("f://file.txt"); try { FileOutputStream fos=new FileOutputStream(file); DataOutputStream dos=new DataOutputStream(fos); int n=123; int i=1; /* for(i=0;i<=100;i++){ dos.writeDouble(Math.random()); dos.writeChars("\n"); }*/ // dos.writeInt(n); dos.writeBytes("123"); dos.flush(); dos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }