write Input Stream To Output Stream - Java java.io

Java examples for java.io:InputStream Read

Description

write Input Stream To Output Stream

Demo Code


//package com.java2s;
import java.io.*;

public class Main {
    public static void writeInputToOutputStream(InputStream inputStream,
            OutputStream outputStream) throws IOException {
        try {//from  w ww  .  j  a  v a 2 s .co  m
            while (true) {
                int readValue = inputStream.read();
                if (readValue < 0)
                    break;
                outputStream.write(readValue);
            }
        } finally {
            inputStream.close();
        }
    }
}

Related Tutorials