org.marketcetera.util.file
Class CopyBytesUtils

java.lang.Object
  extended by org.marketcetera.util.file.CopyBytesUtils

public final class CopyBytesUtils
extends Object

Utilities for copying binary data. The participating media include files, arrays, streams, or some combinations thereof.

Since:
0.6.0
Version:
$Id: CopyBytesUtils.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Method Summary
static void copy(byte[] data, String name)
          Copies an in-memory byte array into the given location.
static long copy(InputStream in, boolean inSkipClose, OutputStream out, boolean outSkipClose)
          Copies a byte stream from the given source to the given sink.
static long copy(InputStream in, boolean skipClose, String out)
          Copies a byte stream from the given source to the given location.
static byte[] copy(String name)
          Copies a byte stream from the given location into memory, returning a byte array.
static long copy(String in, OutputStream out, boolean skipClose)
          Copies a byte stream from the given location to the given sink.
static long copy(String in, String out)
          Copies a byte stream from one given location to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copy

public static long copy(InputStream in,
                        boolean inSkipClose,
                        OutputStream out,
                        boolean outSkipClose)
                 throws I18NException
Copies a byte stream from the given source to the given sink.

Parameters:
in - The byte source, as interpreted by InputStreamWrapper.InputStreamWrapper(InputStream,boolean).
inSkipClose - True if the source stream should not be closed.
out - The byte sink, as interpreted by OutputStreamWrapper.OutputStreamWrapper(OutputStream,boolean).
outSkipClose - True if the sink stream should not be closed.
Returns:
The number of bytes copied.
Throws:
I18NException - Thrown if there is a data read/write error.

copy

public static long copy(String in,
                        String out)
                 throws I18NException
Copies a byte stream from one given location to another.

Parameters:
in - The name of the byte source, as interpreted by InputStreamWrapper.InputStreamWrapper(String).
out - The name of the byte sink, as interpreted by OutputStreamWrapper.OutputStreamWrapper(String).
Returns:
The number of bytes copied.
Throws:
I18NException - Thrown if there is a data read/write error.

copy

public static long copy(InputStream in,
                        boolean skipClose,
                        String out)
                 throws I18NException
Copies a byte stream from the given source to the given location.

Parameters:
in - The byte source, as interpreted by InputStreamWrapper.InputStreamWrapper(InputStream,boolean).
skipClose - True if the source stream should not be closed.
out - The name of the byte sink, as interpreted by OutputStreamWrapper.OutputStreamWrapper(String).
Returns:
The number of bytes copied.
Throws:
I18NException - Thrown if there is a data read/write error.

copy

public static long copy(String in,
                        OutputStream out,
                        boolean skipClose)
                 throws I18NException
Copies a byte stream from the given location to the given sink.

Parameters:
in - The name of the byte source, as interpreted by InputStreamWrapper.InputStreamWrapper(String).
out - The byte sink, as interpreted by OutputStreamWrapper.OutputStreamWrapper(OutputStream,boolean).
skipClose - True if the sink stream should not be closed.
Returns:
The number of bytes copied.
Throws:
I18NException - Thrown if there is a data read/write error.

copy

public static byte[] copy(String name)
                   throws I18NException
Copies a byte stream from the given location into memory, returning a byte array.

Parameters:
name - The name of the byte source, as interpreted by InputStreamWrapper.InputStreamWrapper(String).
Returns:
The array.
Throws:
I18NException - Thrown if there is a data read/write error.

copy

public static void copy(byte[] data,
                        String name)
                 throws I18NException
Copies an in-memory byte array into the given location.

Parameters:
data - The array.
name - The name of the byte sink, as interpreted by OutputStreamWrapper.OutputStreamWrapper(String).
Throws:
I18NException - Thrown if there is a data read/write error.


Copyright © 2012. All Rights Reserved.