Java OutputStream Write copyBytesToStream(ByteArrayOutputStream from, OutputStream to)

Here you can find the source of copyBytesToStream(ByteArrayOutputStream from, OutputStream to)

Description

copy Bytes To Stream

License

Open Source License

Declaration

public static void copyBytesToStream(ByteArrayOutputStream from, OutputStream to) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static void copyBytesToStream(ByteArrayOutputStream from, OutputStream to) throws IOException {
        OutputStream out = new BufferedOutputStream(to);
        try {/*w  w  w  .j ava 2  s .com*/
            from.writeTo(out);
        } finally {
            out.flush();
        }
    }

    public static void copyBytesToStream(byte[] bytes, OutputStream to) throws IOException {
        to.write(bytes);
    }
}

Related

  1. copyBytes(InputStream is, DataOutputStream[] os, long numBytes)
  2. copyBytes(InputStream is, OutputStream bytes)
  3. copyBytes(InputStream iStream, OutputStream oStream)
  4. copyBytesAndClose(final InputStream is, final OutputStream os)
  5. copyBytesToFile(byte[] bytes, File outputFile)
  6. copyBytesToStream(InputStream inputStream, OutputStream outputStream, int length)
  7. copyFile(File fromFile, File toFile)
  8. copyFile(final InputStream in, final OutputStream out, final int size)
  9. copyFile(InputStream in, OutputStream out)