Top Description Fields Constructors Methods
org.apache.catalina.util

public Class IOTools

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, .Reader, .Writer

Contains commonly needed I/O-related methods
Author
Dan Sandberg

Field Summary

Modifier and TypeField and Description
protected static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
flow(Reader
the reader to read from.
reader
,
Writer
the writer to write to.
writer
,
char[]
the char array to use as a buffer
buf
)

Read input from reader and write it to writer until there is no more input from reader.

public static void
flow(Reader
the reader to read from.
reader
,
Writer
the writer to write to.
writer
)

Read input from reader and write it to writer until there is no more input from reader.

public static void
flow(InputStream
input stream the input stream to read from.
is
,
OutputStream
output stream the output stream to write to.
os
)

Read input from input stream and write it to output stream until there is no more input from input stream using a new buffer of the default size (4 KiB).

public static int

Returns:

The number of bytes read
readFully
(InputStream
The source to read from
is
,
byte[]
The buffer to write to
buf
)

Read until EOF or the buffer is filled.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_BUFFER_SIZEback to summary
protected static final int DEFAULT_BUFFER_SIZE

Constructor Detail

IOToolsback to summary
private IOTools()

Method Detail

flowback to summary
public static void flow(Reader reader, Writer writer, char[] buf) throws IOException

Read input from reader and write it to writer until there is no more input from reader.

Parameters
reader:Reader

the reader to read from.

writer:Writer

the writer to write to.

buf:char[]

the char array to use as a buffer

Exceptions
IOException:
IO error
flowback to summary
public static void flow(Reader reader, Writer writer) throws IOException

Read input from reader and write it to writer until there is no more input from reader.

Parameters
reader:Reader

the reader to read from.

writer:Writer

the writer to write to.

Exceptions
IOException:
IO error
See Also
flow(Reader, Writer, char[])
flowback to summary
public static void flow(InputStream is, OutputStream os) throws IOException

Read input from input stream and write it to output stream until there is no more input from input stream using a new buffer of the default size (4 KiB).

Parameters
is:InputStream

input stream the input stream to read from.

os:OutputStream

output stream the output stream to write to.

Exceptions
IOException:
If an I/O error occurs during the copy
readFullyback to summary
public static int readFully(InputStream is, byte[] buf) throws IOException

Read until EOF or the buffer is filled.

Parameters
is:InputStream

The source to read from

buf:byte[]

The buffer to write to

Returns:int

The number of bytes read

Exceptions
IOException:
If an I/O error occurs during the read