net.ontopia.utils
Class StreamUtils

java.lang.Object
  extended by net.ontopia.utils.StreamUtils

public class StreamUtils
extends java.lang.Object

INTERNAL: Utilities for working with streams and readers.

Since:
1.3.3

Constructor Summary
StreamUtils()
           
 
Method Summary
static boolean compare(java.io.InputStream r1, java.io.InputStream r2)
          INTERNAL: Compares the contents of the two InputStreams for equality.
static boolean compare(java.io.Reader r1, java.io.Reader r2)
          INTERNAL: Compares the contents of the two Readers for equality.
static boolean compareAndClose(java.io.InputStream r1, java.io.InputStream r2)
          INTERNAL: Compares the contents of the two InputStream for equality and closes them afterwards.
static java.io.InputStream getInputStream(java.io.File basedir, java.lang.String name)
          INTERNAL: Returns an input stream for the given url.
static java.io.InputStream getInputStream(java.lang.String name)
          INTERNAL: Same as getInputStream(null, name);
static java.net.URL getResource(java.lang.String name)
          INTERNAL: Returns an input stream for the given url.
static byte[] read(java.io.InputStream in)
          INTERNAL: Returns the entire contents of a stream as a byte array.
static byte[] read(java.io.InputStream in, int length)
          INTERNAL: Returns the first given number of bytes of a stream into a byte array.
static java.lang.String read(java.io.Reader in)
          INTERNAL: Returns the entire contents of a stream (well, Reader) as a string.
static java.lang.String readString(java.io.Reader r, long length)
           
static void transfer(java.io.InputStream in, java.io.OutputStream out)
          INTERNAL: Transfers the entire contents of the InputStream to the OutputStream without modifying them in any way.
static void transfer(java.io.Reader in, java.io.Writer out)
          INTERNAL: Transfers the entire contents of the Reader to the Writer without modifying them in any way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamUtils

public StreamUtils()
Method Detail

transfer

public static void transfer(java.io.InputStream in,
                            java.io.OutputStream out)
                     throws java.io.IOException
INTERNAL: Transfers the entire contents of the InputStream to the OutputStream without modifying them in any way.

Throws:
java.io.IOException

transfer

public static void transfer(java.io.Reader in,
                            java.io.Writer out)
                     throws java.io.IOException
INTERNAL: Transfers the entire contents of the Reader to the Writer without modifying them in any way.

Throws:
java.io.IOException
Since:
2.0.4

read

public static java.lang.String read(java.io.Reader in)
                             throws java.io.IOException
INTERNAL: Returns the entire contents of a stream (well, Reader) as a string.

Throws:
java.io.IOException
Since:
1.4

read

public static byte[] read(java.io.InputStream in,
                          int length)
                   throws java.io.IOException
INTERNAL: Returns the first given number of bytes of a stream into a byte array.

Throws:
java.io.IOException
Since:
2.0

read

public static byte[] read(java.io.InputStream in)
                   throws java.io.IOException
INTERNAL: Returns the entire contents of a stream as a byte array.

Throws:
java.io.IOException
Since:
3.3.0

compare

public static boolean compare(java.io.InputStream r1,
                              java.io.InputStream r2)
                       throws java.io.IOException
INTERNAL: Compares the contents of the two InputStreams for equality.

Throws:
java.io.IOException
Since:
4.0

compareAndClose

public static boolean compareAndClose(java.io.InputStream r1,
                                      java.io.InputStream r2)
                               throws java.io.IOException
INTERNAL: Compares the contents of the two InputStream for equality and closes them afterwards.

Throws:
java.io.IOException

compare

public static boolean compare(java.io.Reader r1,
                              java.io.Reader r2)
                       throws java.io.IOException
INTERNAL: Compares the contents of the two Readers for equality.

Throws:
java.io.IOException
Since:
4.0

getInputStream

public static java.io.InputStream getInputStream(java.lang.String name)
                                          throws java.io.IOException
INTERNAL: Same as getInputStream(null, name);

Throws:
java.io.IOException
Since:
3.4.3

getInputStream

public static java.io.InputStream getInputStream(java.io.File basedir,
                                                 java.lang.String name)
                                          throws java.io.IOException
INTERNAL: Returns an input stream for the given url. Supports file: and classpath:. If no scheme given then file system will be checked before classpath. Exception will be thrown if resource is not found when scheme is given. If no scheme was given null is returned. File references will be interpreted relative to basedir. If basedir is null, it will be ignored.

Throws:
java.io.IOException
Since:
5.1.1

getResource

public static java.net.URL getResource(java.lang.String name)
                                throws java.io.IOException
INTERNAL: Returns an input stream for the given url. Supports file: and classpath:. If no schema given then file system will be checked before classpath. Exception will be thrown if resource is not found when schema is given. If no schema was given null is returned.

Throws:
java.io.IOException
Since:
3.4.3

readString

public static java.lang.String readString(java.io.Reader r,
                                          long length)
                                   throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2000-2012 Ontopia.