Package totalcross.io
Class Base64decoderStream
- java.lang.Object
-
- java.io.InputStream
-
- totalcross.io.Base64decoderStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class Base64decoderStream extends java.io.InputStreamReceive a stream of base64 encoded bytes and decode to the original. Given a base 64 encoded image (img64), one may use:Image createImage(String img64) { ByteArrayStream bas = new ByteArrayStream(img64.getBytes()); // get a Stream to read the String InputStream stringInput = bas.asInputStream(); // use ByteArrayStream as a java.io.InputStream compliant object Base64decoderStream decoder = new Base64decoderStream(stringInput); // now we can read the original bytes Stream imgSource = Stream.asStream(decoder); // use Base64decoderStream as a totalcross.io.Stream compliant object return new Image(imgSource); // passing the stream directly to the image for the sake of memory }
-
-
Constructor Summary
Constructors Constructor Description Base64decoderStream(java.io.InputStream base64encodedStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intread()intread(byte[] b, int off, int len)longskip(long n)Unable to skip.
-
-
-
Method Detail
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOExceptionUnable to skip. Will throwIOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
-