-3

I get this ico base64 representation string (example, cut in the middle):

"data:image/x-icon;base64,AAABAAkAAAAAAAEAIADXwgAAlgAAAI...AAA=".

How do i create ico file from it in Java?

Edit: it didn't work with Files.write

  • [Related](https://stackoverflow.com/questions/469695/decode-base64-data-in-java). – user202729 Jan 07 '18 at 13:34
  • @BackSlash In client side I'm using FileUploader to read the uploaded file. First approach was to read file as text - then, in server i tried creating file with Files.write(path, string as byte[]). It seems that when i read it as text, there are many Gibberish characters (any help with this will be great). Then, i moved to reading it as base 64, and tried to use decoder, then to turn it to byte[], and then use Files.write, but that didn't work as well. – user2487087 Jan 07 '18 at 14:48

1 Answers1

0

In previous projects, I did the following:

byte[] data = Base64.decodeBase64(base64string);
try {
    OutputStream stream = new FileOutputStream(output_file_name)
    stream.write(data); 
} catch (Exception e) {
    //Catch IOException errors
}

Hope it helps!

Ele
  • 33,468
  • 7
  • 37
  • 75