* @param filename Filename for saving encoded data
     * @throws java.io.IOException if there is an error
     * @throws NullPointerException if dataToEncode is null
     * @since 2.1
     */
    public static void encodeToFile( byte[] dataToEncode, String filename )
    throws java.io.IOException {
        
        if( dataToEncode == null ){
            throw new NullPointerException( "Data to encode was null." );
        }   // end iff
        
        Base64.OutputStream bos = null;
        try {
            bos = new Base64.OutputStream( 
                  new java.io.FileOutputStream( filename ), Base64.ENCODE );
            bos.write( dataToEncode );
        }   // end try
        catch( java.io.IOException e ) {
            throw e; // Catch and throw to execute finally{} block
        }   // end catch: java.io.IOException
        finally {
            try{ bos.close(); } catch( Exception e ){}
        }   // end finally
        
    }