import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.util.Base64; /* * java util base64 native for jdk 8 */ public class myBase64util { Context mContext; myBase64util(Context c){ mContext = c; } /** * for example: * you can use it in html5 hybrid app in component webview. * In JavaFX to write base64 image in your filesystem **/ public void base64imgDecode(String base64ImageData, String foldername, String imgname){ String capturePathString = '.' + "/" + foldername + "/" + imgname; try{ File file = new File(capturePathString); file.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(file); byte[] decodedString = Base64.getDecoder().decode(base64ImageData); fos.write(decodedString); fos.flush(); fos.close(); } catch(Exception e){ e.printStackTrace(); } } }
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question