edu.iastate.utils.io
Class IOUtils

java.lang.Object
  extended byedu.iastate.utils.io.IOUtils

public abstract class IOUtils
extends java.lang.Object


Field Summary
private static int BLOCK_SIZE
          Block size used when reading the input stream.
 
Constructor Summary
private IOUtils()
          Private constructor to avoid accidental instantiation.
 
Method Summary
static java.io.BufferedReader openInputStream(java.io.InputStream stream)
           
static java.io.BufferedReader openInputStream(java.lang.String pSourceURL)
           
static java.io.BufferedReader openUnixFtpInputStream(java.lang.String ftpServer, java.lang.String userName, java.lang.String password, java.lang.String file, FtpUtils ftp)
          open a passive ftp session
static java.lang.String read(java.io.InputStream input)
          Reads an input stream and returns its contents.
static java.lang.String read(java.io.InputStream inputStream, int contentLength)
          Reads given input stream into a String.
static java.lang.String readIfPossible(java.io.InputStream input)
          Reads the contents of an input stream and returns its contents, if possible.
static java.lang.String readTextFromURL(java.lang.String pSourceURL)
           
static java.lang.String readURL(java.lang.String pSourceURL)
           
static java.lang.String readURL(java.net.URL url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

private static final int BLOCK_SIZE
Block size used when reading the input stream.

See Also:
Constant Field Values
Constructor Detail

IOUtils

private IOUtils()
Private constructor to avoid accidental instantiation.

Method Detail

read

public static java.lang.String read(java.io.InputStream inputStream,
                                    int contentLength)
Reads given input stream into a String.

Parameters:
inputStream - the input stream to read.
contentLength - the length of the content.
Returns:
the input stream contents, or an empty string if the operation fails.

read

public static java.lang.String read(java.io.InputStream input)
                             throws java.io.IOException
Reads an input stream and returns its contents.

Parameters:
input - the input stream to be read.
Returns:
the contents of the stream.
Throws:
java.io.IOException - whenever the operation cannot be accomplished.

readIfPossible

public static java.lang.String readIfPossible(java.io.InputStream input)
Reads the contents of an input stream and returns its contents, if possible. If some exception occurs, returns an empty String.

Parameters:
input - the input stream to be read.
Returns:
the contents of the stream, or empty if reading cannot be accomplished.

readURL

public static java.lang.String readURL(java.net.URL url)

readURL

public static java.lang.String readURL(java.lang.String pSourceURL)

readTextFromURL

public static java.lang.String readTextFromURL(java.lang.String pSourceURL)

openInputStream

public static java.io.BufferedReader openInputStream(java.io.InputStream stream)
Parameters:
stream - InputStream
Returns:
BufferedReader
Since:
2005-03-05

openInputStream

public static java.io.BufferedReader openInputStream(java.lang.String pSourceURL)

openUnixFtpInputStream

public static java.io.BufferedReader openUnixFtpInputStream(java.lang.String ftpServer,
                                                            java.lang.String userName,
                                                            java.lang.String password,
                                                            java.lang.String file,
                                                            FtpUtils ftp)
open a passive ftp session

Parameters:
ftpServer - String
userName - String
password - String
file - String
ftp - FtpUtils - created as 'new FtpUtils()'. You don't need to open it explicitly, but have to close it by yourself. s.t. ftp.closeDataConnection() in your calling function
Returns:
BufferedReader
Since:
2005-03-05