atg.distributor
Class IOTools

java.lang.Object
  extended by atg.distributor.IOTools
All Implemented Interfaces:
DistributorConstants

public class IOTools
extends java.lang.Object
implements DistributorConstants


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from interface atg.distributor.DistributorConstants
DEBUG_PREFIX, DEFAULT_FILE_BUFFER_SIZE, ERROR_PREFIX, FAILURE_FLAG, FILECHECK_CMD, INFO_PREFIX, MAX_RETRIES_FOR_FILE_ACCESS, MY_RESOURCE_NAME, PUT_CMD, SUCCESS_FLAG, WARNING_PREFIX
 
Constructor Summary
IOTools()
          Constructs an instanceof IOTools
 
Method Summary
static java.io.FileInputStream openFileForReading(java.io.File pFile, ApplicationLogging pLog)
          Attempt to open a FileInputStream based on the supplied file.
static java.io.FileOutputStream openFileForWriting(java.io.File pFile, ApplicationLogging pLog)
          Attempt to open a FileOutputStream based on the supplied file.
static boolean writeFile(java.io.File pFilePath, long pFileSize, java.io.DataInputStream pInput, ApplicationLogging pLog)
          Reads the data from the supplied input stream and writes the data to the given file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

IOTools

public IOTools()
Constructs an instanceof IOTools

Method Detail

openFileForWriting

public static java.io.FileOutputStream openFileForWriting(java.io.File pFile,
                                                          ApplicationLogging pLog)
                                                   throws java.io.IOException
Attempt to open a FileOutputStream based on the supplied file. If while opening the output stream we receive an IOException, the system will attempt to reopen the file 3 times. If after the three attempts, it still cannot open the file an IOException will be thrown.

Returns:
a FileOutputStream which points to the supplied file
Throws:
java.io.IOException - if an error occurs while attempting to open the file for writing

openFileForReading

public static java.io.FileInputStream openFileForReading(java.io.File pFile,
                                                         ApplicationLogging pLog)
                                                  throws java.io.IOException
Attempt to open a FileInputStream based on the supplied file. If while opening the output stream we receive an IOException, the system will attempt to reopen the file 3 times. If after the three attempts, it still cannot open the file an IOException will be thrown.

Returns:
a FileOutputStream which points to the supplied file
Throws:
java.io.IOException - if an error occurs while attempting to open the file for writing

writeFile

public static boolean writeFile(java.io.File pFilePath,
                                long pFileSize,
                                java.io.DataInputStream pInput,
                                ApplicationLogging pLog)
                         throws java.io.IOException
Reads the data from the supplied input stream and writes the data to the given file

Parameters:
pFilePath - the file to store the data sent
pFileSize - the total amount of bytes that are being sent from the client
pInput - the input stream to read from the client
Returns:
true if the all the data was received, written to the given file successfully, and the client was properly notified
Throws:
java.io.IOException