|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ckkloverdos.io.IOUtil
public class IOUtil
IO-related utility methods.
Constructor Summary | |
---|---|
IOUtil()
|
Method Summary | |
---|---|
static void |
copy(java.io.InputStream is,
java.io.OutputStream os)
Copies the bytes from is to os . |
static java.lang.String |
getFileExtension(java.io.File file)
Returns the filename extension of the given file. |
static java.lang.String |
getFileExtension(java.lang.String name)
Returns the extension of the given filename. |
static java.lang.String |
getFileLine(java.io.File f,
int line)
Reads the line with the given line number. |
static java.lang.String |
getFileLine(java.io.File f,
int line,
java.lang.String encoding)
Reads the line with the given line number. |
static byte[] |
readBytes(java.io.InputStream is)
Given an stream, we read it exhaustively and return the resulting byte array. |
static byte[] |
readBytes(java.io.InputStream is,
boolean close)
Given an stream, we read it exhaustively and return the resulting byte array. |
static IReadLine |
readLineFromReader(java.io.BufferedReader br)
Creates a IReadLine implementation
from the specified buffered reader. |
static IReadLine |
readLineFromReader(java.io.Reader r)
Creates a IReadLine implementation
from the specified reader. |
static java.lang.String |
readString(java.io.File file)
The file is read as a string, using StringUtil.UTF8 . |
static java.lang.String |
readString(java.io.File file,
java.lang.String encoding)
The file is read as a string, using the provided character encoding . |
static java.lang.String |
readString(java.io.InputStream is)
Given a stream, we read it exhaustively and return the characters contained in the stream as a string. |
static java.lang.String |
readString(java.io.InputStream is,
boolean close)
Given a stream, we read it exhaustively and return the characters contained in the stream as a string. |
static java.lang.String |
readString(java.io.InputStream is,
java.lang.String encoding)
Given an stream, we read it exhaustively and return the characters contained in the stream as a string. |
static java.lang.String |
readString(java.io.InputStream is,
java.lang.String encoding,
boolean close)
Given an stream, we read it exhaustively and return the characters contained in the stream as a string. |
static void |
safeClose(java.io.InputStream is)
Safely closes the input stream, even if it is null , without
throwing any exceptions. |
static void |
safeClose(java.io.Reader r)
Safely closes the reader, even if it is null , without
throwing any exceptions. |
static java.io.InputStream |
safeOpenStream(java.net.URL url)
Safely opens the stream from url . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public IOUtil()
Method Detail |
---|
public static byte[] readBytes(java.io.InputStream is, boolean close) throws java.io.IOException
close
is true
.
is
- The stream
java.io.IOException
public static byte[] readBytes(java.io.InputStream is) throws java.io.IOException
is
- The stream
java.io.IOException
public static java.lang.String readString(java.io.InputStream is, boolean close) throws java.io.IOException
StringUtil.UTF8
character encoding
is used for the translation of bytes to characters.
The stream is closed after reading iff close
is true
.
is
- The channel stream
java.io.IOException
public static java.lang.String readString(java.io.InputStream is) throws java.io.IOException
StringUtil.UTF8
character encoding
is used for the translation of bytes to characters.
is
- The channel stream
java.io.IOException
public static java.lang.String readString(java.io.InputStream is, java.lang.String encoding, boolean close) throws java.io.IOException
close
is true
.
is
- The channel streamencoding
- The requested character encoding. Not null
java.io.IOException
public static java.lang.String readString(java.io.InputStream is, java.lang.String encoding) throws java.io.IOException
is
- The channel streamencoding
- The requested character encoding. Not null
java.io.IOException
public static void copy(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
is
to os
.
is
- os
-
java.io.IOException
public static java.lang.String readString(java.io.File file) throws java.io.IOException
file
is read as a string, using StringUtil.UTF8
.
file
-
java.io.IOException
public static java.lang.String readString(java.io.File file, java.lang.String encoding) throws java.io.IOException
file
is read as a string, using the provided character encoding
.
file
-
java.io.IOException
public static java.io.InputStream safeOpenStream(java.net.URL url)
url
. No exceptions are thrown.
Returns null
on error.
url
- public static void safeClose(java.io.InputStream is)
null
, without
throwing any exceptions.
is
- public static java.lang.String getFileLine(java.io.File f, int line)
f
- line
- public static java.lang.String getFileLine(java.io.File f, int line, java.lang.String encoding)
encoding
is null
, StringUtil.UTF8
is used.
Note: Lines start from 1.
f
- line
- encoding
- public static void safeClose(java.io.Reader r)
null
, without
throwing any exceptions.
r
- public static IReadLine readLineFromReader(java.io.BufferedReader br)
IReadLine
implementation
from the specified buffered reader.
br
- public static IReadLine readLineFromReader(java.io.Reader r)
IReadLine
implementation
from the specified reader.
r
- public static java.lang.String getFileExtension(java.io.File file) throws java.io.IOException
file
-
java.io.IOException
public static java.lang.String getFileExtension(java.lang.String name) throws java.io.IOException
name
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |