Java InputStream to OutputStream copyStream(InputStream in, OutputStream out, String end)

Here you can find the source of copyStream(InputStream in, OutputStream out, String end)

Description

copy Stream

License

Mozilla Public License

Declaration

public static void copyStream(InputStream in, OutputStream out, String end) throws Exception, IOException 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

import java.io.*;

public class Main {

    public static void copyStream(InputStream in, OutputStream out, String end) throws Exception, IOException {
        if (!estDefinit(end))
            throw new Exception("End string can not be null or empty");
        int i = -1, pos = 0;
        while (-1 != (i = in.read())) {
            out.write(i);//from www.j av a 2 s.c o  m
            pos = i == end.charAt(pos) ? pos + 1 : 0;
            if (pos == end.length())
                break;
        }
    }

    public static boolean estDefinit(Object obj) {
        if (null == obj)
            return false;
        else if (obj.equals(""))
            return false;
        return true;
    }
}

Related

  1. copyStream(InputStream in, OutputStream out, int bufferSize)
  2. copyStream(InputStream in, OutputStream out, int bufsize)
  3. copyStream(InputStream in, OutputStream out, int len)
  4. copyStream(InputStream in, OutputStream out, JarEntry entry)
  5. copyStream(InputStream in, OutputStream out, long maxLen)
  6. copyStream(InputStream input, OutputStream output)
  7. copyStream(InputStream input, OutputStream output)
  8. copyStream(InputStream input, OutputStream output)
  9. copyStream(InputStream input, OutputStream output)