Skip to content

Instantly share code, notes, and snippets.

@mutkuensert
Last active May 13, 2025 10:26
Show Gist options
  • Save mutkuensert/0c8aeae393ec8afe424f035e71c3fe29 to your computer and use it in GitHub Desktop.
Save mutkuensert/0c8aeae393ec8afe424f035e71c3fe29 to your computer and use it in GitHub Desktop.
An example that converts base64 string to an input stream without creating a new byte array
import android.util.Base64
import android.util.Base64InputStream
import org.apache.commons.io.input.ReaderInputStream //implementation 'commons-io:commons-io:2.19.0' https://central.sonatype.com/artifact/commons-io/commons-io?smo=true
import tr.com.avivasa.mobileapp.base.BasePresenter
import java.io.StringReader
import java.nio.charset.StandardCharsets
val base64String = "someBase64String"
val inputStream = Base64InputStream(
ReaderInputStream.builder()
.setReader(StringReader(base64String))
.setCharset(StandardCharsets.US_ASCII)
.get(),
Base64.DEFAULT
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment