導出png圖片

public void exportImage(String baseUrl, String imagePath) {
    String base64Info = baseUrl;
    base64Info = base64Info.replaceAll(" ", "+");
    String[] arr = base64Info.split("base64,");
    if (arr != null && arr.length > 1) {
        byte[] buffer = null;
        try {
            buffer = Base64.decode(arr[1].getBytes());
        } catch (Exception e) {
            e.printStackTrace();
        }
        OutputStream output = null;
        try {
            output = new FileOutputStream(new File(imagePath));// 生成png文件
            output.write(buffer);
            output.flush();
            output.close();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章