Kotlin – Encode (Decode) File/Image to Base64

For some purpose like transfering an image through RestfulAPI or saving an image to a DataBase, We need Encoder (Decode) the image to Base64. In the tutorial, JavaSampleApproach will guide you how to use Kotlin language for converting.

Note: Prepare an Image at folder ‘C:\\base64\\image.jpg’

I. Kotlin Encode File/Image to Base64

II. Kotlin Decode Base64 to File/Image

III. Full Sample

By grokonez | February 7, 2018.

Related Posts

4 thoughts on “Kotlin – Encode (Decode) File/Image to Base64”

    1. Try with:
      base64 = android.util.Base64.encodeToString(bytes, 0)
      instead of
      base64 = Base64.getEncoder().encodeToString(bytes)

Got Something To Say:

Your email address will not be published. Required fields are marked *