【FileOutputStream類:write用法】


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();
    }

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM