import sun.misc.*; import java.io.*; public class Base64Test { // Section 6.8 // ftp://ftp.isi.edu/in-notes/rfc2045.txt public Base64Test() { } public static void main(String[] args){ try{ InputStream in; OutputStream out; //encode in = new BufferedInputStream( new FileInputStream( "c:\\atg\\dynamo4.5.0\\doc\\mini\\iMac.jpg" ) ); out = new BufferedOutputStream( new FileOutputStream( "c:\\atg\\dynamo4.5.0\\doc\\mini\\test.txt" ) ); BASE64Encoder encoder = new BASE64Encoder(); encoder.encodeBuffer(in,out); in.close(); out.close(); //decode in = new BufferedInputStream( new FileInputStream( "c:\\atg\\dynamo4.5.0\\doc\\mini\\test.txt" ) ); out = new BufferedOutputStream( new FileOutputStream( "c:\\atg\\dynamo4.5.0\\doc\\mini\\test.jpg" ) ); BASE64Decoder decoder = new BASE64Decoder(); decoder.decodeBuffer(in, out); in.close(); out.close(); }catch(Exception e){ e.printStackTrace(); } } }