public final class IOUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
IOUtils.IgnoreCommentsLineHandler |
static interface |
IOUtils.LineHandler |
static class |
IOUtils.SkipHeaderLineHandler |
Modifier and Type | Field and Description |
---|---|
static String |
ISO_8859_1
ISO-8859-1 character set name.
|
static String |
UTF8
UTF-8 character set name.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkForBytes(InputStream stream)
Checks if a stream has more bytes.
|
static InputStream |
checkForBytes(InputStream stream,
int bufferSize)
Checks if a stream has more bytes.
|
static void |
closeQuietly(Closeable closeable)
Closes a stream and ignores any exceptions.
|
static void |
closeQuietly(ContentStream contentStream)
Closes the stream of a
ContentStream object and ignores any
exceptions. |
static void |
consumeAndClose(InputStream stream)
Consumes and closes the provided stream.
|
static void |
consumeAndClose(Reader reader)
Consumes and closes the provided reader.
|
static void |
copy(InputStream in,
OutputStream out)
Copies all bytes of an input stream to an output stream.
|
static void |
copy(InputStream in,
OutputStream out,
int bufferSize)
Copies all bytes of an input stream to an output stream.
|
static String |
decodeURL(String s)
URL decodes the given string or throws a
CmisRuntimeException if
the charset 'UTF-8' is not available. |
static String |
encodeURL(String s)
URL encodes the given string or throws a
CmisRuntimeException if
the charset 'UTF-8' is not available. |
static String |
readAllLines(InputStream stream)
Reads all lines from a stream and closes the stream.
|
static String |
readAllLinesAndIgnoreComments(InputStream stream)
Reads all lines from a stream, ignores all comments, and closes the
stream.
|
static String |
readAllLinesAndRemoveHeader(InputStream stream)
Reads all lines from a stream, removes the header, and closes the stream.
|
static List<String> |
readAllLinesAsList(InputStream stream)
Reads all lines from a stream, ignores all comments, and closes the
stream.
|
static Map<String,String> |
readAllLinesAsMap(InputStream stream)
Reads all lines from a stream, ignores all comments, and closes the
stream.
|
static String |
readFirstLine(InputStream stream)
Reads the first line from a stream and closes the stream.
|
static void |
readLinesFromStream(InputStream stream,
IOUtils.LineHandler handler)
Reads lines from an UTF-8 encoded stream and closes the stream.
|
static byte[] |
toUTF8Bytes(String s)
Returns UTF-8 bytes of the given string or throws a
CmisRuntimeException if the charset 'UTF-8' is not available. |
static String |
toUTF8String(byte[] bytes)
Converts a UTF-8 encoded byte array into a string or throws a
CmisRuntimeException if the charset 'UTF-8' is not available. |
public static final String UTF8
public static final String ISO_8859_1
public static byte[] toUTF8Bytes(String s)
CmisRuntimeException
if the charset 'UTF-8' is not available.s
- the input stringpublic static String toUTF8String(byte[] bytes)
CmisRuntimeException
if the charset 'UTF-8' is not available.bytes
- the byte arraypublic static String encodeURL(String s)
CmisRuntimeException
if
the charset 'UTF-8' is not available.s
- the string to encodepublic static String decodeURL(String s)
CmisRuntimeException
if
the charset 'UTF-8' is not available.s
- the string to decodepublic static InputStream checkForBytes(InputStream stream, int bufferSize) throws IOException
BufferedInputStream
around the stream and
returns it.stream
- the streambufferSize
- the size of the buffer in bytes if a
BufferedInputStream
has to be creatednull
if the stream doesn't have more bytes, the provided
stream if the provided stream is markable and has more bytes, or
a BufferedInputStream
if the provided stream is not
markable and has more bytesIOException
public static boolean checkForBytes(InputStream stream) throws IOException
stream
- a markable streamtrue
if the stream has more bytes, false
otherwiseIOException
public static void closeQuietly(Closeable closeable)
closeable
- the Closeable
objectpublic static void closeQuietly(ContentStream contentStream)
ContentStream
object and ignores any
exceptions.contentStream
- the content streampublic static void consumeAndClose(InputStream stream)
stream
- the streampublic static void consumeAndClose(Reader reader)
reader
- the readerpublic static void copy(InputStream in, OutputStream out) throws IOException
in
- the input stream, must not be null
out
- the output stream, must not be null
IOException
public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException
in
- the input stream, must not be null
out
- the output stream, must not be null
bufferSize
- the size of the internal buffer, must be positiveIOException
public static void readLinesFromStream(InputStream stream, IOUtils.LineHandler handler) throws IOException
stream
- the streamhandler
- a handler the processes each line.IOException
public static String readFirstLine(InputStream stream) throws IOException
stream
- the input streamIOException
public static String readAllLines(InputStream stream) throws IOException
stream
- the input streamIOException
public static String readAllLinesAndRemoveHeader(InputStream stream) throws IOException
stream
- the input streamIOException
public static String readAllLinesAndIgnoreComments(InputStream stream) throws IOException
stream
- the input streamIOException
public static List<String> readAllLinesAsList(InputStream stream) throws IOException
stream
- the input streamIOException
public static Map<String,String> readAllLinesAsMap(InputStream stream) throws IOException
stream
- the input streamIOException
Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.