MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / encodeToFile

Method encodeToFile

java/src/cx/fbn/encrypt/Base64.java:1392–1412  ·  view source on GitHub ↗

Convenience method for encoding data to a file. As of v 2.3, if there is a error, the method will throw an java.io.IOException. This is new to v2.3! In earlier versions, it just returned false, but in retrospect that's a pretty poor way to handle it. @param dataToEncode byte array of

( byte[] dataToEncode, String filename )

Source from the content-addressed store, hash-verified

1390 * @since 2.1
1391 */
1392 public static void encodeToFile( byte[] dataToEncode, String filename )
1393 throws java.io.IOException {
1394
1395 if( dataToEncode == null ){
1396 throw new NullPointerException( "Data to encode was null." );
1397 } // end iff
1398
1399 Base64.OutputStream bos = null;
1400 try {
1401 bos = new Base64.OutputStream(
1402 new java.io.FileOutputStream( filename ), Base64.ENCODE );
1403 bos.write( dataToEncode );
1404 } // end try
1405 catch( java.io.IOException e ) {
1406 throw e; // Catch and throw to execute finally{} block
1407 } // end catch: java.io.IOException
1408 finally {
1409 try{ bos.close(); } catch( Exception e ){}
1410 } // end finally
1411
1412 } // end encodeToFile
1413
1414
1415 /**

Callers

nothing calls this directly

Calls 2

writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected