See More

/* * ¹¦ÄÜ£ºFileOutputStreamÀà»ù±¾¹¦ÄÜ£¬¶ÁÈ¡Îļþ£¬Ð´³öÎļþ£¬Ã¿´Î¶Áдһ¸ö×Ö½Ú * 1¡¢ */ package com.bj.io; import java.io.*; public class FileOutputStream_t { public static void main(String[] args) { //¶¨ÒåFile¶ÔÏó File file=new File("D:/www/test.txt"); //×Ö½ÚÊä³öÁ÷ FileOutputStream fos=null; try { fos=new FileOutputStream(file); //×Ö·û´® String s="I have a dream.\r\n"; String s1="you have a dream."; //¶¨Òå×Ö½ÚÊý×é //byte bytes[]=new byte[1024]; fos.write(s.getBytes()); fos.write(s1.getBytes()); } catch ( Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ try { fos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }