Last active
May 13, 2025 10:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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