BufferedOutputStream In Java Example

Chapter: Java I/O Last Updated: 21-07-2016 17:08:36 UTC

Program:

            /* ............... START ............... */
                
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;

public class JavaBufferedOutputStream {
	public static void main(String[] args) {

		try {

			String content = "Welcome To JavaScan.com";
			byte[] array = content.getBytes();

			FileOutputStream fis = new FileOutputStream("javaFile.txt");
			BufferedOutputStream bos = new BufferedOutputStream(fis);

			for (byte b : array) {
				bos.write(b);
			}

			bos.close();
			fis.close();

		} catch (Exception ex) {
			System.out.println(ex.getMessage());
		}

	}
}
                /* ............... END ............... */
        

Notes:

  • Java BufferedOutputStream class uses an internal buffer to store data. It adds more efficiency than to write data directly into a stream.
  • The Java.io.BufferedOutputStream class implements a buffered output stream.

Tags

BufferedOutputStream,Java,Java I/O

Similar Programs Chapter Last Updated
Hidden File Check In Java Example Java I/O 20-06-2016
FileWriter In Java Example Java I/O 21-07-2016
FileReader In Java Example Java I/O 21-07-2016
FileOutputStream In Java Example Java I/O 21-07-2016
FileInputStream In Java Example Java I/O 21-07-2016
DataOutputStream In Java Example Java I/O 21-07-2016
DataInputStream In Java Example Java I/O 21-07-2016
CharArrayWriter In Java Example Java I/O 13-04-2016
CharArrayReader In Java Example Java I/O 21-07-2016
ByteArrayOutputStream In Java Example Java I/O 21-07-2016
ByteArrayInputStream In Java Example Java I/O 21-07-2016
BufferedWriter In Java Example Java I/O 21-07-2016
BufferedReader In Java Example Java I/O 21-07-2016
BufferedInputStream In Java Example Java I/O 21-07-2016
ProcessBuilder To Make System Calls In Java Java I/O 19-08-2017

1