Java Code Example for BufferedOutputStream : write(int b) Method

BufferedOutputStream’s write(int b) method overrides write(int b) method of FilterOutputStream. This method writes the specified byte to this output stream.
The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).
Implements the abstract write method of OutputStream.

Parameters: b – the byte.
Throws: IOException – if an I/O error occurs.


/**********************************************************************************
 * Created on Nov, 2004 Copyright(c) https://kodehelp.com All Rights Reserved. 
 **********************************************************************************/
package com.kodehelp.java.io.BufferedOutputStream;

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

/**
 * @author https://kodehelp.com
 *
 */
public class BufferedOutStreamWrite {
	
	/**
	 * @param args
	 */
	public static void main (String args[]){

		BufferedOutputStream bos =null;
		try{
			bos = new BufferedOutputStream(System.out);
			byte[] b = new byte[26];
			for(int i=0; i<26 ; i++){
				bos.write(i+65);
			}
			
			
		}catch(IOException ioe){
			System.out.println("Error while writing to System OutStream" + ioe);
		}finally{
			try
			{
				if(bos != null)
				{
					bos.flush();
					bos.close();
				}
 
			}catch(Exception e){
				e.printStackTrace();
			}
		}
	
	}

}

Please Post Your Comments & Reviews

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.