Android Utililty Methods InputStream Copy

List of utility methods to do InputStream Copy

Description

The list of methods to do InputStream Copy are organized into topic(s).

Method

booleancopyStream(InputStream src, OutputStream dest)
copy Stream
byte[] buffer = new byte[COPYSTREAM_BUFFER_SIZE];
try {
    int size;
    while ((size = src.read(buffer)) != -1) {
        dest.write(buffer, 0, size);
} catch (IOException e) {
    return false;
...
intcopyAllBytes(InputStream in, OutputStream out)
copy All Bytes
int byteCount = 0;
byte[] buffer = new byte[4096];
while (true) {
    int read = in.read(buffer);
    if (read == -1) {
        break;
    out.write(buffer, 0, read);
...
voidcopyRAWFile(InputStream inStream, File newfile)
copy RAW File
try {
    FileOutputStream fs = new FileOutputStream(newfile);
    copyRAWFile(inStream, fs);
    fs.close();
} catch (Exception e) {
    e.printStackTrace();
voidcopyRAWFile(InputStream inStream, FileOutputStream outStream)
copy RAW File
try {
    int bytesum = 0, byteread = 0;
    byte[] buffer = new byte[102400]; 
    while ((byteread = inStream.read(buffer)) != -1) {
        bytesum += byteread;
        System.out.println(bytesum);
        outStream.write(buffer, 0, byteread);
    inStream.close();
} catch (Exception e) {
    e.printStackTrace();