How to write byte to file using BufferedOutputStream() in Java

1 Answer

0 votes
package javaapplication1;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) {

        String sFileName = "d://data.txt";

        try {
            BufferedOutputStream bos;
            try (FileOutputStream fos = new FileOutputStream(sFileName)) {
                bos = new BufferedOutputStream(fos);
                byte b = 97;
                bos.write(b);
                bos.flush();
            }
        } catch (IOException ioe) {
            System.out.println(ioe);
        }
    }
}

// in file:  a

/*
      
run:


  
 */

 



answered Nov 12, 2016 by avibootz
...