Package org.apache.catalina.util
Class IOTools
- java.lang.Object
-
- org.apache.catalina.util.IOTools
-
public class IOTools extends java.lang.Object
Contains commonly needed I/O-related methods- Author:
- Dan Sandberg
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_BUFFER_SIZE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
flow(java.io.InputStream is, java.io.OutputStream 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 (4kB).static void
flow(java.io.Reader reader, java.io.Writer writer)
Read input from reader and write it to writer until there is no more input from reader.static void
flow(java.io.Reader reader, java.io.Writer writer, char[] buf)
Read input from reader and write it to writer until there is no more input from reader.static int
readFully(java.io.InputStream is, byte[] buf)
Read until EOF or the buffer is filled.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
protected static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
flow
public static void flow(java.io.Reader reader, java.io.Writer writer, char[] buf) throws java.io.IOException
Read input from reader and write it to writer until there is no more input from reader.- Parameters:
reader
- the reader to read from.writer
- the writer to write to.buf
- the char array to use as a buffer- Throws:
java.io.IOException
- IO error
-
flow
public static void flow(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
Read input from reader and write it to writer until there is no more input from reader.- Parameters:
reader
- the reader to read from.writer
- the writer to write to.- Throws:
java.io.IOException
- IO error- See Also:
flow( Reader, Writer, char[] )
-
flow
public static void flow(java.io.InputStream is, java.io.OutputStream os) throws java.io.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 (4kB).- Parameters:
is
- input stream the input stream to read from.os
- output stream the output stream to write to.- Throws:
java.io.IOException
- If an I/O error occurs during the copy
-
readFully
public static int readFully(java.io.InputStream is, byte[] buf) throws java.io.IOException
Read until EOF or the buffer is filled.- Parameters:
is
- The source to read frombuf
- The buffer to write to- Returns:
- The number of bytes read
- Throws:
java.io.IOException
- If an I/O error occurs during the read
-
-