Skip to content

Instantly share code, notes, and snippets.

View szahn's full-sized avatar

Stuart Zahn szahn

View GitHub Profile
@szahn
szahn / EncodeBased64Binary.java
Created October 8, 2012 16:34 — forked from utsengar/EncodeBased64Binary.java
Encode a file to base64 binary in Java
import org.apache.commons.codec.binary.Base64;
private String encodeFileToBase64Binary(String fileName)
throws IOException {
File file = new File(fileName);
byte[] bytes = loadFile(file);
byte[] encoded = Base64.encodeBase64(bytes);
String encodedString = new String(encoded);