Java Code Example for BufferedOutputStream : write(byte[]b, int off, int len) Method

BufferedOutputStream’s write(byte[]b,int off,int len) method writes len bytes from specified array of byte starting from offset off to the outputstream.

This method stores bytes from the given array into this stream’s buffer, flushing the buffer to the underlying output stream as needed. If the requested length is at least as large as this stream’s buffer, however, then this method will flush the buffer and write the bytes directly to the underlying output stream.

b – the data.
off – the start offset in the data.
len – the number of bytes to write.

 * Created on Nov, 2004 Copyright(c) All Rights Reserved. 


 * @author
public class BufferedOutStreamWrite {
	 * @param args
	public static void main (String args[]){

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


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.