Copy Stream : Stream « File « Android

Copy Stream


class Main {
  public static void CopyStream(InputStream is, OutputStream os) {
    final int buffer_size = 1024;
    try {
      byte[] bytes = new byte[buffer_size];
      for (;;) {
        int count =, 0, buffer_size);
        if (count == -1)
        os.write(bytes, 0, count);
    } catch (Exception ex) {


Related examples in the same category

1.Playing Back Audio Streams
2.Stream Proxy
3.Ini File Stream Reader
4.Read InputStream fully to a string
5.Read Stream to byte array String From Stream
7.Read stream Fully
8.Read InputStream with ByteArrayOutputStream
9.get Resource As Stream, Loads the resource from classpath
10.InputStream to byte array, copy Reader and Writer,
11.InputStream that notifies listeners of its progress.
12.String to InputStream
13.Context.getFileStreamPath To String To Bytes
16.Load/save Int Map Data
17.Write InputStream into a StringBuilder