com.mucommander.io.base64
Class Base64OutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.mucommander.io.base64.Base64OutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class Base64OutputStream
extends java.io.OutputStream

This OuputStream encodes supplied data to Base64 encoding and writes it to the underlying OutputStream.

Author:
Maxence Bernard, with the exception of the Base64 description which was found on the Web.
See Also:
Base64Encoder

Constructor Summary
Base64OutputStream(java.io.OutputStream out, boolean insertLineBreaks)
          Creates a new Base64OutputStream using the underlying OutputStream to write the base64-encoded data to.
 
Method Summary
 void close()
          Writes padding if necessary and closes the underlying stream.
 void write(int i)
           
 void writePadding()
          Writes padding '=' characters to the underlying OutputStream if there currently is an unfinished 3-byte group.
 
Methods inherited from class java.io.OutputStream
flush, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64OutputStream

public Base64OutputStream(java.io.OutputStream out,
                          boolean insertLineBreaks)
Creates a new Base64OutputStream using the underlying OutputStream to write the base64-encoded data to.

Parameters:
out - the underlying OutputStream to write the base64-encoded data to
insertLineBreaks - if true, line breaks will be inserted after every 80 characters written
Method Detail

writePadding

public void writePadding()
                  throws java.io.IOException
Writes padding '=' characters to the underlying OutputStream if there currently is an unfinished 3-byte group. If it's not the case, then this method is a no-op.

Throws:
java.io.IOException - if the padding characters could not be written to the underlying OutputStream.

write

public void write(int i)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Writes padding if necessary and closes the underlying stream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard