[ Back | Previous | Next ]

How to convert from Base64 encoding to ASCII

Package:
sun.misc.*
Product:
JDK
Release:
1.0.2
Related Links:
BASE64Decoder
Comment:
public static void main(java.lang.String[] args) {
 // Insert code to start the application here.
 try {
  File f = new File(args[0]);
  BufferedOutputStream bos = new BufferedOutputStream(new
FileOutputStream(f));
  //BufferedInputStream bis = new BufferedInputStream( System.in);
  BufferedInputStream bis = new BufferedInputStream( new
FileInputStream(new File("input.txt")));
  sun.misc.BASE64Decoder base64 = new sun.misc.BASE64Decoder();
  base64.decodeBuffer(bis, bos);
  int ch = 0;
  while ((ch = bis.read()) >= 0) {
   bos.write(ch);
  }
  bos.flush();
  bos.close();
 } catch (Throwable t) {
  t.printStackTrace();
  System.exit(1);
 } finally {
 }
}