java.io

Class BufferedOutputStream

Implemented Interfaces:
Closeable, Flushable
Known Direct Subclasses:
MonitorOutputStream

public class BufferedOutputStream
extends FilterOutputStream

The class implements a buffered output stream. By setting up such an output stream, an application can write bytes to the underlying output stream without necessarily causing a call to the underlying system for each byte written.
Since:
JDK1.0

Field Summary

protected byte[]
buf
The internal buffer where data is stored.
protected int
count
The number of valid bytes in the buffer.

Fields inherited from class java.io.FilterOutputStream

out

Constructor Summary

BufferedOutputStream(OutputStream out)
Creates a new buffered output stream to write data to the specified underlying output stream.
BufferedOutputStream(OutputStream out, int size)
Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.

Method Summary

void
flush()
Flushes this buffered output stream.
void
write(b[] , int off, int len)
Writes len bytes from the specified byte array starting at offset off to this buffered output stream.
void
write(int b)
Writes the specified byte to this buffered output stream.

Methods inherited from class java.io.FilterOutputStream

close, flush, write, write, write

Methods inherited from class java.io.OutputStream

close, flush, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

buf

protected byte[] buf
The internal buffer where data is stored.

count

protected int count
The number of valid bytes in the buffer. This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data.

Constructor Details

BufferedOutputStream

public BufferedOutputStream(OutputStream out)
Creates a new buffered output stream to write data to the specified underlying output stream.
Parameters:
out - the underlying output stream.
Usages and Demos :

View More Examples of BufferedOutputStream(OutputStream out)
   1:         try {
   2:             OutputStream out = new BufferedOutputStream(Httpd.logfile.getOutputStream());
   3:             out.write(date.toString().getBytes());
   4:             out.write((byte) '\t');
   5:             out.write(method.toString().getBytes());

View Full Code Here
   1:         try {
   2:             OutputStream out = new BufferedOutputStream(Httpd.logfile.getOutputStream());
   3:             out.write(date.toString().getBytes());
   4:             out.write((byte) '\t');
   5:             out.write(method.toString().getBytes());

View Full Code Here
   1:       fis=new BufferedInputStream(_src.getInputStream());
   2:       fos=new BufferedOutputStream(_dst.getOutputStream());
   3: 
   4:       long sl=_src.length();
   5:       long bt=0;

View Full Code Here
   1:         _input = _socket.getInputStream();
   2:         _output = new BufferedOutputStream(_socket.getOutputStream());
   3:       }
   4:       catch(IOException e)
   5:       {

View Full Code Here
   1: public void setSocket(java.net.Socket client) throws java.io.IOException {
   2:   if (client != sock);    setSocket(client, new ObjectInputStream(client.getInputStream()), new ObjectOutputStream(new BufferedOutputStream(client.getOutputStream())));
   3: }
   4: public void setSocket(java.net.Socket client, ObjectInputStream in, ObjectOutputStream out) throws java.io.IOException {
   5:   sock = client;

View Full Code Here

BufferedOutputStream

public BufferedOutputStream(OutputStream out,
                            int size)
Creates a new buffered output stream to write data to the specified underlying output stream with the specified buffer size.
Parameters:
out - the underlying output stream.
size - the buffer size.
Throws:
IllegalArgumentException - if size <= 0.
Usages and Demos :

View More Examples of BufferedOutputStream(OutputStream out,int size)
   1:       ByteArrayOutputStream baos = new ByteArrayOutputStream(24);
   2:       BufferedOutputStream bos = new BufferedOutputStream(baos, 12);
   3: 
   4:       String str = "The Kroger on College Mall Rd. in Bloomington " +
   5:         "used to sell Kroger brand froze pizzas for 68 cents. " +

View Full Code Here
   1:         output =
   2:           new DataOutputStream(new BufferedOutputStream(_output_, 1024));
   3:         output.writeBytes(__query.toString());
   4:         output.flush();

View Full Code Here
   1:       FileOutputStream fos = new FileOutputStream(destFile);
   2:       dest = new BufferedOutputStream(fos, BUFFER_SIZE);
   3:       while ((count = jis.read(data, 0, BUFFER_SIZE)) != -1) {
   4:         dest.write(data, 0, count);
   5:       }

View Full Code Here
   1:         ByteArrayOutputStream bos = new ByteArrayOutputStream();
   2:         BufferedOutputStream out = new BufferedOutputStream(bos, ZBUF_SIZE);
   3:         ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
   4:         InflaterInputStream in = new InflaterInputStream(bis, new Inflater(), ZBUF_SIZE);
   5:         byte[] buf = new byte[ZBUF_SIZE];

View Full Code Here
   1:                     FileOutputStream fos = new FileOutputStream(destFilePath);
   2:                     dest = new BufferedOutputStream(fos, BUFFER);
   3:                     while ((count = jis.read(data, 0, BUFFER)) != -1) {
   4:                         dest.write(data, 0, count);
   5:                     }

View Full Code Here

Method Details

flush

public void flush()
            throws IOException
Flushes this buffered output stream. This forces any buffered output bytes to be written out to the underlying output stream.
Specified by:
flush in interface Flushable
Overrides:
flush in interface FilterOutputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of flush()
   1:       BufferedInputStream bis = new BufferedInputStream(istream);
   2:       BufferedOutputStream bos = new BufferedOutputStream(out);
   3:      
   4:         ...
   5:       bis.close();
   6:       bos.flush();
   7:     } catch (Exception e) {
   8:       e.printStackTrace();
   9:     }

View Full Code Here
   1:       ByteArrayOutputStream baos = new ByteArrayOutputStream();
   2:       BufferedOutputStream bos = new BufferedOutputStream(baos);
   3: 
   4:         ...
   5:       }
   6:       bos.flush();
   7:       bos.close();
   8:       return baos.toByteArray();
   9:     } catch (IOException ioe) {

View Full Code Here
   1:             OutputStream outstream = socket.getOutputStream();
   2:             BufferedOutputStream boutstream = new BufferedOutputStream(outstream);
   3:             boutstream.write(identifier.getBytes(), 0, identifier.getBytes().length);
   4:         ...
   5:             boutstream.flush();
   6:             outstream.close();
   7:             socket.close();
   8:         } catch (UnknownHostException e) {

View Full Code Here
   1:     File file = new File(targetDir, entry.getName());
   2:     BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(
   3:         file));
   4:         ...
   5:     }
   6:     out.flush();
   7:     out.close();
   8:     in.close();
   9:   }

View Full Code Here
   1: 
   2: import java.io.BufferedOutputStream;
   3: import java.io.ByteArrayOutputStream;
   4:         ...
   5:         OutputStream out = response.getOutputStream();
   6:         BufferedOutputStream buffOut = new BufferedOutputStream(out, 1024 * 1024);
   7:         buffer.writeTo(buffOut);
   8:         ...
   9:         buffOut.flush();
  10:     }

View Full Code Here

write

public void write(b[] ,
                  int off,
                  int len)
            throws IOException
Writes len bytes from the specified byte array starting at offset off to this buffered output stream.

Ordinarily 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. Thus redundant BufferedOutputStreams will not copy data unnecessarily.

Overrides:
write in interface FilterOutputStream
Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(b[] ,int off,int len)
   1: 
   2:     BufferedOutputStream bos;
   3:     byte[] b=new byte[10];
   4:         ...
   5:     public TagWriter(String name) throws IOException {
   6:     bos=new BufferedOutputStream(new FileOutputStream(name),4096);
   7:     }
   8:         ...
   9:     public void write(byte[] b,int off,int len) throws IOException {
  10:     bos.write(b,off,len);
  11:     }
  12:         ...
  13:     b[1]=(byte) l;
  14:     bos.write(b,0,2);

View Full Code Here
   1: import java.io.PushbackInputStream;
   2: import java.io.BufferedOutputStream;
   3: import java.io.FileOutputStream;
   4:         ...
   5:             PushbackInputStream in = new PushbackInputStream(xInputFile.getInputStream());
   6:             BufferedOutputStream out_1 = new BufferedOutputStream( new FileOutputStream(strippedfile_video), 5120000);
   7:             BufferedOutputStream out_2 = new BufferedOutputStream( new FileOutputStream(strippedfile_audio), 4096000);
   8:         ...
   9:                 if (videolength > 0)
  10:                     out_1.write(array, 0x200, videolength);
  11: 
  12:         ...
  13:                 if (audiolength > 0)
  14:                     out_2.write(array, 0x9200, audiolength);

View Full Code Here
   1:     BufferedInputStream bis  = new BufferedInputStream(is);
   2:     BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(daydir+File.separatorChar+getFilename()));
   3:     
   4:         ...
   5:     while(-1 != read){
   6:       bos.write(abuffer,0, read);
   7:       read = bis.read(abuffer);
   8:     }
   9:     

View Full Code Here
   1: import java.io.BufferedInputStream;
   2: import java.io.BufferedOutputStream;
   3: import java.io.FileInputStream;
   4:         ...
   5: 
   6:           final BufferedOutputStream out =
   7:         ...
   8:             new BufferedOutputStream(conn.getOutputStream());
   9:           int bytesRead = 0;
  10:         ...
  11:           while ((bytesRead = in.read(b)) != -1) {
  12:             out.write(b, 0, bytesRead);

View Full Code Here
   1:         while (count != -1) {
   2:           out.write(b, 0, count);
   3:           System.out.print(".");
   4:         ...
   5:     int bufferSize;
   6:     BufferedOutputStream out = null;
   7:     InputStream in = null;
   8:         ...
   9: 
  10:         out = new BufferedOutputStream(new FileOutputStream(sampleFile), 
  11:                                        bufferSize);
  12:         ...
  13:           System.out.print(".");
  14:           out.write(b, 0, count);

View Full Code Here

write

public void write(int b)
            throws IOException
Writes the specified byte to this buffered output stream.
Overrides:
write in interface FilterOutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(int b)
   1: 
   2: import java.io.BufferedOutputStream;
   3: import java.io.ByteArrayOutputStream;
   4:         ...
   5:         char[] pwd = "password".toCharArray();
   6:         BufferedOutputStream bStream = null;
   7:         {
   8:         ...
   9:             OutputStream s2 = new OpenSSLPBEOutputStream(s1, PBESupport.ALG_MD5_DES, 1, pwd);
  10:             bStream = new BufferedOutputStream(s2);
  11:         }
  12:         ...
  13:         for (int i = 1; i <= 10 * 1000; i++) {
  14:             bStream.write((i + ": ").getBytes("ASCII"));

View Full Code Here
   1:         BufferedReader sin = new BufferedReader(new InputStreamReader(sock.getInputStream())) ;
   2:         BufferedOutputStream sou = new BufferedOutputStream(sock.getOutputStream()) ;
   3:         
   4:         ...
   5:                 
   6:                 sou.write(String.valueOf(retc).getBytes(aspt.getCharSet())) ;
   7:         ...
   8:                 sou.write("\n".getBytes(aspt.getCharSet())) ;
   9:         ...
  10:                 sou.write(bdr.toString().getBytes(aspt.getCharSet())) ;

View Full Code Here
   1: 
   2: import java.io.BufferedOutputStream;
   3: import java.io.BufferedWriter;
   4:         ...
   5: 
   6:             BufferedOutputStream out =
   7:         ...
   8:               new BufferedOutputStream(socket.getOutputStream());
   9:             String s = CommonUtils.getUserName() + " [Credence]\r\n";
  10:         ...
  11:             byte[] bytes=s.getBytes();
  12:             out.write(bytes);

View Full Code Here
   1: 
   2: import java.io.BufferedOutputStream;
   3: import java.io.File;
   4:         ...
   5:         throws IOException {
   6:         final BufferedOutputStream out =
   7:         ...
   8:             new BufferedOutputStream(new FileOutputStream(file));
   9:         save(out, config);
  10:         ...
  11:             saveConvert(key, ESCAPE_KEY, out);
  12:             out.write("=");

View Full Code Here
   1: 
   2:     client.write(request);
   3:     
   4:         ...
   5:       writer.startElement ("methodName");
   6:       writer.write(method);
   7:       writer.endElement ("methodName");
   8:         ...
   9:     SSLSocket sslSocket = null;
  10:     BufferedOutputStream output;
  11:     BufferedInputStream input;
  12:         ...
  13:       sslSocket.startHandshake();
  14:       output = new BufferedOutputStream

View Full Code Here