org.mortbay.util

Class IO

Implemented Interfaces:
LifeCycle, Serializable

public class IO
extends ThreadPool

IO Utilities. Provides stream handling utilities in singleton Threadpool implementation accessed by static members.

Nested Class Summary

Nested classes/interfaces inherited from class org.mortbay.util.ThreadPool

ThreadPool.PoolThread

Field Summary

static String
CRLF
static byte[]
CRLF_BYTES
static int
bufferSize

Fields inherited from class org.mortbay.util.ThreadPool

__DAEMON, __PRIORITY

Method Summary

static void
close(InputStream is)
closes an input stream, and logs exceptions
static void
close(OutputStream os)
closes an output stream, and logs exceptions
static void
copy(InputStream in, OutputStream out)
Copy Stream in to Stream out until EOF or exception.
static void
copy(InputStream in, OutputStream out, long byteCount)
Copy Stream in to Stream for byteCount bytes or until EOF or exception.
static void
copy(Reader in, Writer out)
Copy Reader to Writer out until EOF or exception.
static void
copy(Reader in, Writer out, long byteCount)
Copy Reader to Writer for byteCount bytes or until EOF or exception.
static void
copyThread(InputStream in, OutputStream out)
Copy Stream in to Stream out until EOF or exception.
static void
copyThread(Reader in, Writer out)
Copy Stream in to Stream out until EOF or exception in own thread
static boolean
delete(File file)
Delete File.
static OutputStream
getNullStream()
static Writer
getNullWriter()
void
handle(Object o)
Run copy for copyThread()
static IO
instance()
static String
toString(InputStream in)
Read input stream to string.

Methods inherited from class org.mortbay.util.ThreadPool

getIdleThreads, getMaxIdleTimeMs, getMaxThreads, getMinThreads, getName, getPoolName, getThreads, getThreadsPriority, handle, isDaemon, isStarted, join, run, setDaemon, setMaxIdleTimeMs, setMaxStopTimeMs, setMaxThreads, setMinThreads, setName, setPoolName, setThreadsPriority, shrink, start, stop, stopJob

Field Details

CRLF

public static final String CRLF

CRLF_BYTES

public static final byte[] CRLF_BYTES

bufferSize

public static int bufferSize

Method Details

close

public static void close(InputStream is)
closes an input stream, and logs exceptions
Parameters:
is - the input stream to close

close

public static void close(OutputStream os)
closes an output stream, and logs exceptions
Parameters:
os - the output stream to close

copy

public static void copy(InputStream in,
                        OutputStream out)
            throws IOException
Copy Stream in to Stream out until EOF or exception.

copy

public static void copy(InputStream in,
                        OutputStream out,
                        long byteCount)
            throws IOException
Copy Stream in to Stream for byteCount bytes or until EOF or exception.

copy

public static void copy(Reader in,
                        Writer out)
            throws IOException
Copy Reader to Writer out until EOF or exception.

copy

public static void copy(Reader in,
                        Writer out,
                        long byteCount)
            throws IOException
Copy Reader to Writer for byteCount bytes or until EOF or exception.

copyThread

public static void copyThread(InputStream in,
                              OutputStream out)
Copy Stream in to Stream out until EOF or exception. in own thread

copyThread

public static void copyThread(Reader in,
                              Writer out)
Copy Stream in to Stream out until EOF or exception in own thread

delete

public static boolean delete(File file)
Delete File. This delete will recursively delete directories - BE CAREFULL
Parameters:
file - The file to be deleted.

getNullStream

public static OutputStream getNullStream()
Returns:
An outputstream to nowhere

getNullWriter

public static Writer getNullWriter()
Returns:
An writer to nowhere

handle

public void handle(Object o)
Run copy for copyThread()
Overrides:
handle in interface ThreadPool

instance

public static IO instance()

toString

public static String toString(InputStream in)
            throws IOException
Read input stream to string.

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.