Perform stream copy.

@param input
The input stream.
@param output
The output stream.
@throws Exception
The stream copy failure exception.
962179
public static void transfer(final InputStream input,
			final OutputStream output) throws Exception {
		final byte[] data = new byte[SIZE];
		while (true) {
			final int count = input.read(data, 0, SIZE);
			if (count == EOF) {
				break;
			}
			output.write(data, 0, count);
		}
	}
1312310
public static void copy(String in, Writer out) throws IOException {
        assert in != null : "No input String specified";
        assert out != null : "No output Writer specified";

        try {
            out.write(in);
        } finally {
            try {
                out.close();
            } catch (IOException ex) {
            }
        }
    }
254756
public static long copyAndCloseOutput(InputStream input, OutputStream output) throws IOException {
		try (OutputStream outputStream = output) {
			return copy(input, outputStream);
		}
	}
502828
public static int copyAndCloseOutput(Reader input, Writer output) throws IOException {
		try {
			return copy(input, output);
		} finally {
			output.close();
		}
		
	}
66560
public void setInputStream(InputStream stream) {
        try {
            cachedInputStream = new ByteArrayOutputStream();
            IOUtils.copy(stream, cachedInputStream);
        } catch (IOException e) {
            LOG.error("Exception on writing InputStream.", e);
        }
    }
426568
public static void copy(InputStream in, OutputStream out, long byteCount) throws IOException {
        byte buffer[] = new byte[bufferSize];
        int len = bufferSize;

        if (byteCount >= 0) {
            while (byteCount > 0) {
                int max = byteCount < bufferSize ? (int) byteCount : bufferSize;
                len = in.read(buffer, 0, max);

                if (len == -1)
                    break;

                byteCount -= len;
                out.write(buffer, 0, len);
            }
        } else {
            while (true) {
                len = in.read(buffer, 0, bufferSize);
                if (len < 0)
                    break;
                out.write(buffer, 0, len);
            }
        }
    }
748600
public static long copy(final Reader input, final Writer output) throws IOException {
		return CharStreams.copy(input, output);
	}
235624
public void copyToOutputStream(OutputStream o) throws IOException {
		long left = end - start;
		int BUFF_SIZE = 4096;
		byte buf[] = new byte[BUFF_SIZE];
		RandomAccessFile raf = new RandomAccessFile(file, "r");
		try {
			raf.seek(start);
			while(left > 0) {
				int amtToRead = (int) Math.min(left, BUFF_SIZE);
				int amtRead = raf.read(buf, 0, amtToRead);
				if(amtRead < 0) {
					throw new IOException("Not enough to read! EOF before expected region end");
				}
				o.write(buf,0,amtRead);
				left -= amtRead;
			}
		} finally {
			raf.close();
		}
	}
848801
public static long copyAndCloseBoth(InputStream input, OutputStream output) throws IOException {
		try (InputStream inputStream = input) {
			return copyAndCloseOutput(inputStream, output);
		}
	}
739021
public static void copyStream(InputStream copyFrom, File copyTo,
			GeoPackageProgress progress) throws IOException {

		OutputStream to = new FileOutputStream(copyTo);

		copyStream(copyFrom, to, progress);

		// Try to delete the file if progress was cancelled
		if (progress != null && !progress.isActive()
				&& progress.cleanupOnCancel()) {
			copyTo.delete();
		}
	}
438992
public static void copyStreamSafely( InputStream in, ByteArrayOutputStream os ) throws IOException {

		try {
			copyStreamUnsafelyUseWithCaution( in, os );

		} finally {
			in.close();
		}
	}
99592
public static void copyThenClose(InputStream input, OutputStream output)
      throws IOException {
    copy(input, output);
    input.close();
    output.close();
  }
57473
public static void copy(byte[] in, OutputStream out) throws IOException {
		Assert.notNull(in, "No input byte array specified");
		Assert.notNull(out, "No OutputStream specified");
		out.write(in);
	}
735642
public static long copy(
                    final InputStream input,
                    final File output
                    )
    throws IOException
    {
        OutputStream  stream_output = null;
        long  size = 0L;
        try {
            stream_output = new FileOutputStream( output );
                            //throws FileNotFoundException
            size = copy( input, stream_output );
                   //throws IOException
        } finally {
            try {
                stream_output.close();
            } catch (Exception ex) {
                //ignorable
            }
        }

        return size;

    }
903990
public static void copy(byte[] in, File out) throws IOException {
        assert in != null : "No input byte array specified";
        assert out != null : "No output File specified";
        ByteArrayInputStream inStream = new ByteArrayInputStream(in);
        OutputStream outStream = new BufferedOutputStream(new FileOutputStream(out));
        copy(inStream, outStream);
    }
290415
public static long copy(final InputStream input, final OutputStream output) throws IOException {
		return ByteStreams.copy(input, output);
	}
343722
public static void copyReader(OutputStream outs, Reader reader) throws IOException
   {
      try
      {
         OutputStreamWriter writer = new OutputStreamWriter(outs, StandardCharsets.UTF_8);
         char[] bytes = new char[1024];
         int r = reader.read(bytes);
         while (r > 0)
         {
            writer.write(bytes, 0, r);
            r = reader.read(bytes);
         }
      }
      catch (IOException e)
      {
         throw e;
      }
      finally{
         reader.close();
      }
   }