org.fcrepo.server.utilities
Class StreamUtility

java.lang.Object
  extended by org.fcrepo.server.utilities.StreamUtility

public abstract class StreamUtility
extends Object

Utility methods for working with character-based or raw sequences of data.

Author:
Chris Wilper

Constructor Summary
StreamUtility()
           
 
Method Summary
static void enc(char[] in, int start, int length, StringBuffer out)
          Appends an XML-appropriate encoding of the given range of characters to the given StringBuffer.
static void enc(char in, StringBuffer out)
          Appends an XML-appropriate encoding of the given character to the given StringBuffer.
static String enc(String in)
          Returns an XML-appropriate encoding of the given String.
static void enc(String in, StringBuffer out)
          Appends an XML-appropriate encoding of the given String to the given StringBuffer.
static byte[] getBytes(InputStream in)
          Gets a byte array for the given input stream.
static InputStream getStream(String string)
          Gets a stream for the given string.
static void pipeStream(InputStream in, OutputStream out, int bufSize)
          Copies the contents of an InputStream to an OutputStream, then closes both.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamUtility

public StreamUtility()
Method Detail

enc

public static String enc(String in)
Returns an XML-appropriate encoding of the given String.

Parameters:
in - The String to encode.
Returns:
A new, encoded String.

enc

public static void enc(String in,
                       StringBuffer out)
Appends an XML-appropriate encoding of the given String to the given StringBuffer.

Parameters:
in - The String to encode.
out - The StringBuffer to write to.

enc

public static void enc(char[] in,
                       int start,
                       int length,
                       StringBuffer out)
Appends an XML-appropriate encoding of the given range of characters to the given StringBuffer.

Parameters:
in - The char buffer to read from.
start - The starting index.
length - The number of characters in the range.
out - The StringBuffer to write to.

enc

public static void enc(char in,
                       StringBuffer out)
Appends an XML-appropriate encoding of the given character to the given StringBuffer.

Parameters:
in - The character.
out - The StringBuffer to write to.

pipeStream

public static void pipeStream(InputStream in,
                              OutputStream out,
                              int bufSize)
                       throws IOException
Copies the contents of an InputStream to an OutputStream, then closes both.

Parameters:
in - The source stream.
out - The target stram.
bufSize - Number of bytes to attempt to copy at a time.
Throws:
IOException - If any sort of read/write error occurs on either stream.

getBytes

public static byte[] getBytes(InputStream in)
                       throws IOException
Gets a byte array for the given input stream.

Throws:
IOException

getStream

public static InputStream getStream(String string)
Gets a stream for the given string.



Copyright © 2012 DuraSpace. All Rights Reserved.