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.
Parameters:
b – the data.
off – the start offset in the data.
len – the number of bytes to write.
/**********************************************************************************
* 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++){
b[i]= (byte) (i+65);
}
bos.write(b, 0, 26);
}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();
}
}
}
}