com.ebmwebsourcing.easycommons.io
Class IOHelper

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.io.IOHelper

public class IOHelper
extends Object

Author:
Marc Jambert - EBM WebSourcing

Method Summary
static void close(Closeable closeable)
           
static String getLine(File file, int lineNum)
          Get the line of the specified file corresponding to the specified line number.
static byte[] readFileAsBytes(File file)
           
static String readFileAsString(File file)
          Read the specified file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

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 line
lineNum - 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 © 2015 Petals Link. All rights reserved.