Skip to content

Instantly share code, notes, and snippets.

@aniljava
Created May 11, 2012 07:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aniljava/2658222 to your computer and use it in GitHub Desktop.
Save aniljava/2658222 to your computer and use it in GitHub Desktop.
Convert Base64 Encoded data to Font OTF/TTF
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.nio.ByteBuffer;
public class FontFromBase64 {
public static void main(String[] args) throws Exception {
String infile = "text.txt";
String outfile = "font.otf";
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
BufferedReader reader = new BufferedReader(new FileReader(new File(infile)));
FileOutputStream out = new FileOutputStream(outfile);
String line = "";
while ((line = reader.readLine()) != null) {
ByteBuffer buffer = decoder.decodeBufferToByteBuffer(line);
out.write(buffer.array());
}
out.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment