Copy Stream : Stream « File « Android






Copy Stream

   
import java.io.InputStream;
import java.io.OutputStream;

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 = is.read(bytes, 0, buffer_size);
        if (count == -1)
          break;
        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
6.read 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
14.stream To String
15.stream To Bytes
16.Load/save Int Map Data
17.Write InputStream into a StringBuilder