Image.base64.Base64ImageConvertor.java
Package image;import sun.misc.base64decoder;import sun.misc.base64encoder;import java.io.* ;p ublic class base64imageconvertor { public static string convertimagetostring (File file) throws Exception { base64encoder base64encoder = new base64encoder (); fileinputstream fis = new fileinputstream (file); ByteArrayOutputStream byteArrayOutputStream = new Bytearrayoutputstream (); base64encoder.encodebuffer (fis, Bytearrayoutputstream); string str = Bytearrayoutputstream.tostring (); fis.close (); bytearraYoutputstream.close (); return str; } public static void convertstringtoimage (String str,File DestFile) throws Exception { Bytearrayinputstream bytearrayinputstream = new bytearrayinputstream (Str.getBytes ()); FileOutputStream fos = new FileOutputStream (destfile); base64decoder base64decoder = new base64decoder (); Base64decoder.decodebuffer (Bytearrayinputstream, fos); Bytearrayinputstream.close (); fos.close (); } }
Java Base64 Picture codec