code: public static void encodeToFile(byte[] dataToEncode, String filename) throws IOException {
  		if (dataToEncode == null) {
  			throw new NullPointerException("Data to encode was null.");
  		}
  
  		Base64.OutputStream bos = null;
  		try {
  			bos = new Base64.OutputStream(new java.io.FileOutputStream(filename), Base64.ENCODE);
  			bos.write(dataToEncode);
  		} catch (IOException e) {
  			throw e; // Catch and throw to execute finally{} block
  		} finally {
  			try {
  				if (bos != null) {
  					bos.close();
  				}
  			} catch (Exception e) {
  			}
  		}
  	}
docs: Convenience method for encoding data to a file.
  
  <p>As of v 2.3, if there is a error,
  the method will throw an java.io.IOException. <b>This is new to v2.3!</b>
  In earlier versions, it just returned false, but
  in retrospect that's a pretty poor way to handle it.</p>
  
  @param dataToEncode byte array of data to encode in base64 form
  @param filename Filename for saving encoded data
  @throws IOException if there is an error
  @throws NullPointerException if dataToEncode is null
  @since 2.1