重複の可能性:
Java で Base64 データをデコードする
enter code here
base64 文字列の画像がdata:image/png;base64,iVBORw0KGgoAAAANS....
あります。この文字列を画像に変換してサーバーに保存したいと思います。Javaでこれを行った例はありますか。
エラーが発生しています: タイプ org.apache.tomcat.util.buf.CharChunk を解決できません。必要な .class ファイル (2 行目) から間接的に参照されます。
これは私のコードです。何が間違っているのかわかりません。
String encodedString = citizens.getPhoto();
byte[] ba = Base64.decode(encodedString);
decodedString = new String(ba);
try {
byte[] imageByteArray = decoder.decodeBuffer(citizens.getPhoto());
FileOutputStream imageOutFile = new FileOutputStream(
"/resources/photos/mypic.jpg");
imageOutFile.write(imageByteArray);
imageOutFile.close();
logger.info("Image Successfully Manipulated!");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}