org.foray.common
Class IOUtil

java.lang.Object
  extended by org.foray.common.IOUtil

public final class IOUtil
extends Object

I/O utilities. This class should be replaced as soon as Jakarta Commons IO announces its first release. TODO: Replace with Jakarta Commons I/O.


Method Summary
static String baseFileName(String fileName)
          Strips the extension off the end of a file name, returning the base portion of the file name.
static void copyStream(InputStream in, OutputStream out)
          Copies the contents of the InputStream over to the OutputStream.
static byte[] toByteArray(InputStream in, int initialTargetBufferSize)
          Loads the contents of the InputStream to a byte array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

copyStream

public static void copyStream(InputStream in,
                              OutputStream out)
                       throws IOException
Copies the contents of the InputStream over to the OutputStream. This method doesn't close the streams.

Parameters:
in - InputStream to read from
out - OutputStream to write to
Throws:
IOException - In case of an I/O problem

toByteArray

public static byte[] toByteArray(InputStream in,
                                 int initialTargetBufferSize)
                          throws IOException
Loads the contents of the InputStream to a byte array. The InputStream isn't closed.

Parameters:
in - InputStream to read from
initialTargetBufferSize - initial number of bytes to allocate (expected size to avoid a lot of reallocations)
Returns:
byte[] the array of bytes requested
Throws:
IOException - In case of an I/O problem

baseFileName

public static String baseFileName(String fileName)
Strips the extension off the end of a file name, returning the base portion of the file name. For example, if the input is "myfile.txt", the output will be "myfile".

Parameters:
fileName - The file name with the extension intact.
Returns:
The file name with the extension removed.


Copyright © 2017. All rights reserved.