Copies the original image into the output image.  If it can't do a copy a new image is created and returned
@param original Original image
@param output (Optional) Storage for copy.
@return The copied image.  May be a new instance
770072
public static BufferedImage checkCopy( BufferedImage original , BufferedImage output ) {
		ColorModel cm = original.getColorModel();
		boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();

		if( output == null || original.getWidth() != output.getWidth() || original.getHeight() != output.getHeight() ||
				original.getType() != output.getType() ) {
			WritableRaster raster = original.copyData(original.getRaster().createCompatibleWritableRaster());
			return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
		}

		original.copyData(output.getRaster());
		return output;
	}
279867
public static int copy(InputStream in, OutputStream out) throws IOException {
        BeanUtil.requireNonNull(in, "No InputStream specified");
        BeanUtil.requireNonNull(out, "No OutputStream specified");
        int byteCount = 0;
        byte[] buffer = new byte[4096];
        int bytesRead1;
        for (; (bytesRead1 = in.read(buffer)) != -1; byteCount += bytesRead1) {
            out.write(buffer, 0, bytesRead1);
        }
        out.flush();
        return byteCount;
    }
906625
public static void copy(Resource in, Resource out) throws IOException {
	in.copyTo(out, false);
    }
1067283
public static long copy(
                    final Reader input,
                    final Writer output
                    )
    throws IOException
    {
        _LOG_.debug( "begin copy" );

        @SuppressWarnings( "resource" )
        BufferedReader  b_input = (BufferedReader.class.isInstance( input )
                                    ? BufferedReader.class.cast( input )
                                    : new BufferedReader( input ));
        @SuppressWarnings( "resource" )
        BufferedWriter  b_output = (BufferedWriter.class.isInstance( output )
                        ? BufferedWriter.class.cast( output )
                        : new BufferedWriter( output ));

        char[]  buffer = new char[512];
        long  size = 0;
        try {
            while (true) {
                int  n = b_input.read( buffer );
                               //@throws IOException
                if (n == -1) {
                    break;
                }
                b_output.write( buffer, 0, n );
                       //@throws IOException
                size += n;
            }
        } finally {
            try {
                b_output.flush();
            } catch (Exception ex) {
                //ignorable
            }
        }

        _LOG_.debug( "end copy: #bytes=" + size );
        return size;
    }
848801
public static long copyAndCloseBoth(InputStream input, OutputStream output) throws IOException {
		try (InputStream inputStream = input) {
			return copyAndCloseOutput(inputStream, output);
		}
	}
602874
private KieServerHttpRequest copy(final InputStream input, final OutputStream output ) throws IOException {
        return new CloseOperation<KieServerHttpRequest>(input, ignoreCloseExceptions) {

            @Override
            public KieServerHttpRequest run() throws IOException {
                final byte[] buffer = new byte[bufferSize];
                int read;
                while( (read = input.read(buffer)) != -1 ) {
                    output.write(buffer, 0, read);
                }
                return KieServerHttpRequest.this;
            }
        }.call();
    }
405151
public static <T extends ImageBase<T>> T checkDeclare(T input, T output) {
		if (output == null) {
			output = (T) input.createNew(input.width, input.height);
		} else {
			output.reshape(input.width, input.height);
		}
		return output;
	}
465249
public FDistort output( ImageBase output ) {
		if( this.output == null || this.output.width != output.width || this.output.height != output.height ) {
			distorter = null;
		}
		this.output = output;
		return this;
	}
1299639
public static int copy(File in, File out) throws IOException {
		Assert.notNull(in, "No input File specified");
		Assert.notNull(out, "No output File specified");
		return copy(new BufferedInputStream(new FileInputStream(in)),
			new BufferedOutputStream(new FileOutputStream(out)));
	}
391966
public static int copy(Resource in, File out) throws IOException {
        assert in != null : "No input File specified";
        assert out != null : "No output File specified";
        return copy(new BufferedInputStream(in.getInputStream()),
                new BufferedOutputStream(new FileOutputStream(out)));
    }
100606
public static long copy(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[2 * 1024];
        long total = 0;
        int count;
        while ((count = input.read(buffer)) != -1) {
            output.write(buffer, 0, count);
            total += count;
        }

        return total;
    }
374113
private CssFormatter copy( @Nullable StringBuilder output ) {
        try {
            CssFormatter formatter = (CssFormatter)clone();
            formatter.output = output == null ? state.pool.get() : output;
            formatter.insets = state.pool.get();
            formatter.insets.append( insets );
            return formatter;
        } catch( CloneNotSupportedException ex ) {
            throw new LessException( ex );
        }
    }
577348
public static long copy(
                    final File input,
                    final OutputStream output
                    )
    throws IOException
    {
        long  size = 0L;
        InputStream  file_input = null;
        try {
            file_input = new FileInputStream( input );
                       //throws FileNotFoundException
            size = copy( file_input, output );
                   //throws IOException
        } finally {
            try {
                file_input.close();
            } catch (Exception ex) {
                //ignorable
            }
        }

        return size;
    }
655964
@Override
    public void copyFrom(final CopyFrom obj) {
        final EntryInformationImpl info = (EntryInformationImpl) obj;
        setAuthor(info.getAuthor());
        setBlock(info.getBlock());

        if (info.getDuration() != null) {
            setDuration(new Duration(info.getDuration().getMilliseconds()));
        }

        setExplicit(info.getExplicit());

        try {
            if (info.getImage() != null) {
                setImage(new URL(info.getImage().toExternalForm()));
            }
        } catch (final MalformedURLException e) {
            LOG.debug("Error copying URL:" + info.getImage(), e);
        }

        if (info.getKeywords() != null) {
            setKeywords(info.getKeywords().clone());
        }

        setSubtitle(info.getSubtitle());
        setSummary(info.getSummary());
        setClosedCaptioned(info.getClosedCaptioned());
        setOrder(info.getOrder());
    }
106686
protected T createCopy (Kryo kryo, T original) {
		return (T)kryo.newInstance(original.getClass());
	}
1044119
public static ImageOutputStream getImageOutputStream(OutputStream out) throws IORuntimeException {
		try {
			return ImageIO.createImageOutputStream(out);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
148937
public static void copy(InputStream input, OutputStream output, int bufferSize) throws IOException {
        int availableBytes = input.available();
        log.debug("copy - bufferSize: {} available: {}", bufferSize, availableBytes);
        byte[] buf = null;
        if (availableBytes > 0) {
            if (availableBytes >= bufferSize) {
                buf = new byte[bufferSize];
            } else {
                buf = new byte[availableBytes];
            }
            int bytesRead = input.read(buf);
            while (bytesRead != -1) {
                output.write(buf, 0, bytesRead);
                bytesRead = input.read(buf);
                log.trace("Bytes read: {}", bytesRead);
            }
            output.flush();
        } else {
            log.debug("Available is 0, attempting to read anyway");
            buf = new byte[bufferSize];
            int bytesRead = input.read(buf);
            while (bytesRead != -1) {
                output.write(buf, 0, bytesRead);
                bytesRead = input.read(buf);
                log.trace("Bytes read: {}", bytesRead);
            }
            output.flush();
        }
    }