com.ebmwebsourcing.easycommons.io
Class IOHelper
java.lang.Object
com.ebmwebsourcing.easycommons.io.IOHelper
public class IOHelper
- extends Object
- Author:
- Marc Jambert - EBM WebSourcing
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
close
public static void close(Closeable closeable)
getLine
public static final String getLine(File file,
int lineNum)
throws 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:
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 String readFileAsString(File file)
throws IOException
- Read the specified file
- Parameters:
file - the file to read
- Returns:
- the content of the file
- Throws:
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(File file)
throws IOException
- Throws:
IOException
Copyright © 2013 Petals Link. All rights reserved.