Android Utililty Methods OutputStream Write

List of utility methods to do OutputStream Write

Description

The list of methods to do OutputStream Write are organized into topic(s).

Method

voidcopy(String input, OutputStream output)
Serialize chars from a String to bytes on an OutputStream, and flush the OutputStream.
StringReader in = new StringReader(input);
OutputStreamWriter out = new OutputStreamWriter(output);
copy(in, out);
out.flush();
voidwriteBom(OutputStream outputStream, String encoding)
Writes the BOM(Byte Order Mark) to the file.
if (outputStream != null && encoding != null) {
    byte[] b = null;
    if (UTF8.equals(encoding)) {
        b = new byte[3];
        b[0] = (byte) 0xef;
        b[1] = (byte) 0xbb;
        b[2] = (byte) 0xbf;
    } else if (UTF16LE.equals(encoding)) {
...
intwriteSInt24ToStream(final OutputStream destination, final int value)
write S Int To Stream
final int absValue = Math.abs(value);
destination
        .write((byte) (((value < 0 ? 0x80 : 0) | (absValue >> 16)) & 0xFF));
destination.write((byte) ((absValue >> 8) & 0xFF));
destination.write((byte) (absValue & 0xFF));
return 3;
voidcopy(InputStream in, OutputStream out)
copy
if (in == null)
    throw new NullPointerException("InputStream is null!");
if (out == null)
    throw new NullPointerException("OutputStream is null");
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
...
voidwriteByte(final String str, final OutputStream out, Map cache)
write Byte
byte[] result = cache.get(str);
if (result == null) {
    result = getStringInUtf8(str);
    cache.put(str, result);
out.write(result);
voiduint32ToStream(long value, OutputStream stream)
uint To Stream
stream.write((byte) (0xFFL & (value >> 0)));
stream.write((byte) (0xFFL & (value >> 8)));
stream.write((byte) (0xFFL & (value >> 16)));
stream.write((byte) (0xFFL & (value >> 24)));
voiduint64ToStream(long value, OutputStream stream)
uint To Stream
stream.write((byte) (0xFFL & (value >> 0)));
stream.write((byte) (0xFFL & (value >> 8)));
stream.write((byte) (0xFFL & (value >> 16)));
stream.write((byte) (0xFFL & (value >> 24)));
stream.write((byte) (0xFFL & (value >> 32)));
stream.write((byte) (0xFFL & (value >> 40)));
stream.write((byte) (0xFFL & (value >> 48)));
stream.write((byte) (0xFFL & (value >> 56)));
...
voidwriteFile(InputStream inputStream, OutputStream outputStream)
write File
final byte[] buf = new byte[10240];
int len;
while ((len = inputStream.read(buf)) != -1) {
    outputStream.write(buf, 0, len);
outputStream.flush();
closeIOStream(outputStream);
closeIOStream(inputStream);
...
intputLong(OutputStream out, final long value, final int fitInBytes)
put Long
long tmpValue = value;
for (int i = 0; i < fitInBytes; ++i) {
    out.write((byte) (tmpValue & 0xff));
    tmpValue >>>= 8;
return fitInBytes;
booleanoutputSubFile(InputStream is, String subFile, String targetPath, String filename)
output Sub File
if (is == null || targetPath.equals("") || targetPath == null
        || filename.equals("") || filename == null
        || subFile.equals("") || subFile == null) {
    return false;
ZipInputStream in = new ZipInputStream(is);
ZipEntry entry = null;
try {
...