public final class

StreamUtils

extends Object
java.lang.Object
   ↳ org.andengine.util.StreamUtils

Class Overview

(c) 2010 Nicolas Gramlich (c) 2011 Zynga Inc.

Summary

Constants
int IO_BUFFER_SIZE
Public Constructors
StreamUtils()
Public Methods
final static void close(Closeable pCloseable)
Closes the specified stream.
final static void copy(InputStream pInputStream, OutputStream pOutputStream, int pByteLimit)
Copy the content of the input stream into the output stream, using a temporary byte array buffer whose size is defined by IO_BUFFER_SIZE.
final static void copy(InputStream pInputStream, byte[] pData)
final static void copy(InputStream pInputStream, OutputStream pOutputStream)
final static void copy(InputStream pInputStream, ByteBuffer pByteBuffer)
final static boolean copyAndClose(InputStream pInputStream, OutputStream pOutputStream)
final static void flushCloseStream(OutputStream pOutputStream)
Flushes and closes the specified stream.
final static void flushCloseWriter(Writer pWriter)
Flushes and closes the specified stream.
final static String readFully(InputStream pInputStream)
final static void streamToBytes(InputStream pInputStream, int pByteLimit, byte[] pData)
final static void streamToBytes(InputStream pInputStream, int pByteLimit, byte[] pData, int pOffset)
final static byte[] streamToBytes(InputStream pInputStream)
final static byte[] streamToBytes(InputStream pInputStream, int pReadLimit)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int IO_BUFFER_SIZE

Constant Value: 8192 (0x00002000)

Public Constructors

public StreamUtils ()

Public Methods

public static final void close (Closeable pCloseable)

Closes the specified stream.

Parameters
pCloseable The stream to close.

public static final void copy (InputStream pInputStream, OutputStream pOutputStream, int pByteLimit)

Copy the content of the input stream into the output stream, using a temporary byte array buffer whose size is defined by IO_BUFFER_SIZE.

Parameters
pInputStream The input stream to copy from.
pOutputStream The output stream to copy to.
pByteLimit not more than so much bytes to read, or unlimited if StreamUtils#END_OF_STREAM.
Throws
IOException If any error occurs during the copy.

public static final void copy (InputStream pInputStream, byte[] pData)

Throws
IOException

public static final void copy (InputStream pInputStream, OutputStream pOutputStream)

Throws
IOException

public static final void copy (InputStream pInputStream, ByteBuffer pByteBuffer)

Throws
IOException

public static final boolean copyAndClose (InputStream pInputStream, OutputStream pOutputStream)

public static final void flushCloseStream (OutputStream pOutputStream)

Flushes and closes the specified stream.

Parameters
pOutputStream The stream to close.

public static final void flushCloseWriter (Writer pWriter)

Flushes and closes the specified stream.

Parameters
pWriter The Writer to close.

public static final String readFully (InputStream pInputStream)

Throws
IOException

public static final void streamToBytes (InputStream pInputStream, int pByteLimit, byte[] pData)

Throws
IOException
See Also
  • {@link StreamUtils#streamToBytes(InputStream, int, byte[], int)}

public static final void streamToBytes (InputStream pInputStream, int pByteLimit, byte[] pData, int pOffset)

Parameters
pInputStream the sources of the bytes.
pByteLimit the amount of bytes to read.
pData the array to place the read bytes in.
pOffset the offset within pData.
Throws
IOException

public static final byte[] streamToBytes (InputStream pInputStream)

Throws
IOException

public static final byte[] streamToBytes (InputStream pInputStream, int pReadLimit)

Throws
IOException