package test; import java.io.FileOutputStream; import java.io.IOException; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/11/9 14:50 */ public class FileOutputStreamDemo2 { public static void main(String[] args) throws IOException { /** *字節輸出流操作步驟: *A:創建字節輸出流對象 *B:調用write()方法 *C:釋放資源 * *public void write(int b):寫一個字節 *public void write(byte[] b):寫一個字節數組 *public void write(byte[] b,int off,int len):寫一個字節數組的一部分 */ FileOutputStream fos = new FileOutputStream("fos.txt"); byte[] bys = {97,98,99,100,101}; fos.write('1'); fos.write(bys); fos.write(bys, 0, 2); fos.close(); } }