Read from InputStream and write to OutputStream : OutputStream « File Input Output « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Book
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
SCJP
Java » File Input Output » OutputStreamScreenshots 
Read from InputStream and write to OutputStream
   



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

public class Main {
  /**
   * Read input from input stream and write it to output stream 
   * until there is no more input from input stream.
   *
   @param is input stream the input stream to read from.
   @param os output stream the output stream to write to.
   @param buf the byte array to use as a buffer
   */
  public static void flowInputStream is, OutputStream os, byte[] buf 
      throws IOException {
      int numRead;
      while ( (numRead = is.read(buf) ) >= 0) {
          os.write(buf, 0, numRead);
      }
  
}

   
    
    
  
Related examples in the same category
1.String Buffer OutputStream
2.A null output stream. All data written to this stream is ignored.
3.Memory Byte Array OutputStream
4.Compare the contents of two Streams to determine if they are equal or not.
5.Byte Counting OutputStream
6.Counting OutputStream
7.A utility class that allows for easy simple obfuscation of streamed data
w_w___w___.___ja__v__a2_s_.__c___o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.