org.openqa.selenium.server
Class IOHelper

java.lang.Object
  extended by org.openqa.selenium.server.IOHelper

public class IOHelper
extends java.lang.Object

Utility class for java.io annoyances.


Constructor Summary
IOHelper()
           
 
Method Summary
static void close(java.io.InputStream stream)
           
static void copyStream(java.io.InputStream in, java.io.OutputStream out)
          Copy remaining stream content to another stream.
static void copyStream(java.io.InputStream in, java.io.OutputStream out, int copyBufferSize)
          Copy remaining stream content to another stream.
static byte[] readFile(java.lang.String filePath)
          Read a file on the file system and return its content as a stream of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOHelper

public IOHelper()
Method Detail

close

public static void close(java.io.InputStream stream)

readFile

public static byte[] readFile(java.lang.String filePath)
                       throws java.io.IOException
Read a file on the file system and return its content as a stream of bytes.

Parameters:
filePath - Path of the file to read. Cannot be null.
Returns:
File content. Never null.
Throws:
java.io.IOException - on error

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out)
                       throws java.io.IOException
Copy remaining stream content to another stream.

Parameters:
in - Input stream to copy (remaining) content from. Cannot be null.
out - Output stream to copy content to. Cannot be null.
Throws:
java.io.IOException - on IO error.
java.lang.AssertionError - If in or out is null.

copyStream

public static void copyStream(java.io.InputStream in,
                              java.io.OutputStream out,
                              int copyBufferSize)
                       throws java.io.IOException
Copy remaining stream content to another stream.

Parameters:
in - Input stream to copy (remaining) content from. Cannot be null.
out - Output stream to copy content to. Cannot be null.
copyBufferSize - Size of the maximum chunk of data that will be copied in one step. A buffer a this size will be allocated internally so beware of the usual speed vs. memory tradeoff. Must be strictly positive.
Throws:
java.io.IOException - on IO error.
java.lang.AssertionError - If copyBufferSize is negative, in is null or out is null.


Copyright © 2011. All Rights Reserved.