com.mysql.management.util
Class Streams

java.lang.Object
  extended by com.mysql.management.util.Streams

public class Streams
extends java.lang.Object

Stream operation utility methods.

Version:
$Id: Streams.java,v 1.12 2005/12/01 21:45:31 eherman Exp $
Author:
Eric Herman

Field Summary
static java.lang.String RESOURCE_SEPARATOR
           
 
Constructor Summary
Streams()
           
 
Method Summary
 void copy(java.io.InputStream from, java.io.OutputStream to)
          Reads the data from the Input stream and writes to the output stream Buffers each stream.
 void createFileFromResource(java.lang.String resourceName, java.io.File file)
          Copies a resource to the location specified by the File parameter.
 void expandResourceJar(java.io.File outputDir, java.lang.String jarResourceName)
          If the jar exists as a resource, the contents of the jar will be expanded on the file system in the location specified by the File parameter.
 java.io.InputStream getResourceAsStream(java.lang.Class aClass, java.lang.String name)
          Convenience method to check for MissingResource (null stream)
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Uses ClassLoader which loaded Streams.class to obtain resource
 java.util.Properties loadProperties(java.lang.String resourceName, java.io.PrintStream err)
           
 java.lang.String readString(java.io.InputStream from)
          reads the entire contents of stream into a String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_SEPARATOR

public static final java.lang.String RESOURCE_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

Streams

public Streams()
Method Detail

copy

public void copy(java.io.InputStream from,
                 java.io.OutputStream to)
          throws java.io.IOException
Reads the data from the Input stream and writes to the output stream Buffers each stream. Terminates when a read from the Input stream results in EOF

Throws:
java.io.IOException

readString

public java.lang.String readString(java.io.InputStream from)
                            throws java.io.IOException
reads the entire contents of stream into a String

Throws:
java.io.IOException

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Uses ClassLoader which loaded Streams.class to obtain resource

Returns:
an InputStream
Throws:
java.util.MissingResourceException

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.Class aClass,
                                               java.lang.String name)
Convenience method to check for MissingResource (null stream)

Returns:
an InputStream
Throws:
java.util.MissingResourceException

createFileFromResource

public void createFileFromResource(java.lang.String resourceName,
                                   java.io.File file)
Copies a resource to the location specified by the File parameter.


expandResourceJar

public void expandResourceJar(java.io.File outputDir,
                              java.lang.String jarResourceName)
If the jar exists as a resource, the contents of the jar will be expanded on the file system in the location specified by the File parameter. If any files already exist, they will not be over-written.


loadProperties

public java.util.Properties loadProperties(java.lang.String resourceName,
                                           java.io.PrintStream err)


Copyright © 2004-2011. All Rights Reserved.