Babu
Babu

Reputation: 1

When i am trying to convert a base64 to image i am getting the following error Cannot resolve overloaded method 'write'

val decoder = new BASE64Decoder
val decodedBytes = decoder.decodeBuffer(base64String)
val uploadFile = "C:/Users/BabuSuku/Downloads/SpineorDownloads/test.png"
val image = ImageIO.read(new ByteArrayInputStream(decodedBytes))
val f = new Nothing(uploadFile)
ImageIO.write(image, "png", uploadFile)

Upvotes: 0

Views: 110

Answers (1)

jps
jps

Reputation: 22545

you passed a string as third parameter to write. You need a Filevariable instead. Change the last two lines accordingly:

val decoder = new BASE64Decoder
val decodedBytes = decoder.decodeBuffer(base64String)
val uploadFile = "C:/Users/BabuSuku/Downloads/SpineorDownloads/test.png"
val image = ImageIO.read(new ByteArrayInputStream(decodedBytes))
val f = new File(uploadFile)
ImageIO.write(image, "png", f)

see Docs

Upvotes: 1

Related Questions