com.ebmwebsourcing.easycommons.io
Class IOHelper
java.lang.Object
com.ebmwebsourcing.easycommons.io.IOHelper
public class IOHelper
- extends java.lang.Object
|
Method Summary |
static void |
close(java.io.Closeable closeable)
|
static java.lang.String |
getLine(java.io.File file,
int lineNum)
Get the line of the specified file corresponding to the specified line
number. |
static byte[] |
readFileAsBytes(java.io.File file)
|
static java.lang.String |
readFileAsString(java.io.File file)
Read the specified file |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
close
public static void close(java.io.Closeable closeable)
getLine
public static final java.lang.String getLine(java.io.File file,
int lineNum)
throws java.io.IOException
- Get the line of the specified file corresponding to the specified line
number. Each time this method is called, the file is open, read until the
specified line number and closed.
- Parameters:
file - the file to read the linelineNum - the number of the line in the specified file
- Returns:
- a String containing the contents of the line, not including any
line-termination characters, or null if the specified line number
is greater than the line number of the file
- Throws:
java.io.IOException - if the file does not exist, is a directory rather than a
regular file, or for some other reason cannot be opened for
reading, if a security manager exists and its checkRead
method denies read access to the file or if an I/O error
occurs
readFileAsString
public static final java.lang.String readFileAsString(java.io.File file)
throws java.io.IOException
- Read the specified file
- Parameters:
file - the file to read
- Returns:
- the content of the file
- Throws:
java.io.IOException - if the file does not exist, is a directory rather than a
regular file, or for some other reason cannot be opened for
reading, if a security manager exists and its checkRead
method denies read access to the file or if an I/O error
occurs
readFileAsBytes
public static byte[] readFileAsBytes(java.io.File file)
throws java.io.IOException
- Throws:
java.io.IOException
Copyright © 2011 Petals Link. All Rights Reserved.