com.norconex.commons.lang.io
Class IOUtil

java.lang.Object
  extended by com.norconex.commons.lang.io.IOUtil

public final class IOUtil
extends Object

I/O related utility methods.

Author:
Pascal Essiembre

Method Summary
static String[] head(InputStream is, int lineQty)
          Gets the first lines from an input stream.
static String[] tail(InputStream is, int lineQty)
          Gets the last lines from an input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

tail

public static String[] tail(InputStream is,
                            int lineQty)
                     throws IOException
Gets the last lines from an input stream. This method is null-safe. If the input stream is null or empty, an empty string array will be returned. For files, one should use FileUtil.tail(java.io.File, int) which is more efficient, especially on large files.

Parameters:
is - input stream
lineQty - maximum number of lines to return
Returns:
lines as a string array
Throws:
IOException - problem reading lines

head

public static String[] head(InputStream is,
                            int lineQty)
                     throws IOException
Gets the first lines from an input stream. This method is null-safe. If the input stream is null or empty, an empty string array will be returned.

Parameters:
is - input stream
lineQty - maximum number of lines to return
Returns:
lines as a string array
Throws:
IOException - problem reading lines


Copyright © 2008-2013 Norconex Inc.. All Rights Reserved.