As the title indicates, I want to know how to convert an image to a base64 string in Java. How can I do this?
With elmah. io's free image to Base64 encoder, it's easy to copy and paste markup or style for exactly your codebase. Simply drag and drop, upload, or provide an image URL in the controls above and the encoder will quickly generate a Base64 encoded version of that image.
Use the Base64
class.
If you're on pre-Java 8, have a look at one of the following resources:
The example at exampledepot.com
or Base64Coder - an open-source Base64 encoder/decoder in Java
or the Base64 class in the org.apache.commons.codec.binary package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With