com.ebasetech.ufs.utility
Class FileUtil

java.lang.Object
  extended bycom.ebasetech.ufs.utility.FileUtil

public class FileUtil
extends java.lang.Object


Constructor Summary
FileUtil()
           
 
Method Summary
static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix, java.io.File near)
          Create a temporary file, Slightly smarter version of File.createTempFile
static byte[] rawReadEntireFile(java.io.File fromFile)
          read file of bytes without conversion
static byte[] rawReadEntireFile(java.lang.String fromFile)
          read file of bytes without conversion
static java.lang.String readEntireFile(java.io.File fromFile)
          Get all text in a file.
static java.lang.String readEntireFile(java.io.File fromFile, java.lang.String encoding)
          Get all text in a file.
static java.lang.String readEntireFile(java.lang.String fromFile)
          Get all text in a file.
static java.lang.String readEntireFile(java.lang.String fromFile, java.lang.String encoding)
          Get all text in a file.
static void writeEntireFile(java.io.File toFile, java.lang.String text)
          Write all the text in a file
static void writeEntireFile(java.io.File toFile, java.lang.String text, java.lang.String encoding)
          Write all the text in a file
static void writeEntireFile(java.lang.String toFile, java.lang.String text)
          Write all the text in a file
static void writeEntireFile(java.lang.String toFile, java.lang.String text, java.lang.String encoding)
          Write all the text in a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

createTempFile

public static java.io.File createTempFile(java.lang.String prefix,
                                          java.lang.String suffix,
                                          java.io.File near)
                                   throws java.io.IOException
Create a temporary file, Slightly smarter version of File.createTempFile

Parameters:
prefix - beginning letters of filename
suffix - ending letters of filename.
near - directory where to put file, or file to place this temp file near in the same directory. null means put the temp file in the current directory.
Returns:
A temporary file. It will not automatically delete on program completion, however.
Throws:
java.io.IOException

rawReadEntireFile

public static byte[] rawReadEntireFile(java.io.File fromFile)
                                throws java.io.IOException
read file of bytes without conversion

Parameters:
fromFile - file to read
Returns:
byte array representing whole file
Throws:
java.io.IOException

rawReadEntireFile

public static byte[] rawReadEntireFile(java.lang.String fromFile)
                                throws java.io.IOException
read file of bytes without conversion

Parameters:
fromFile - file to read
Returns:
byte array representing whole file
Throws:
java.io.IOException

readEntireFile

public static java.lang.String readEntireFile(java.io.File fromFile)
                                       throws java.io.IOException
Get all text in a file.

Parameters:
fromFile - file where to get the text.
Returns:
all the text in the File.
Throws:
java.io.IOException

readEntireFile

public static java.lang.String readEntireFile(java.io.File fromFile,
                                              java.lang.String encoding)
                                       throws java.io.IOException,
                                              java.io.UnsupportedEncodingException
Get all text in a file.

Parameters:
fromFile - file where to get the text.
encoding - name of the encoding to use to translate the bytes in the file into chars e.g. "windows-1252" "UTF-8" "UTF-16"
Returns:
all the text in the File.
Throws:
java.io.IOException
java.io.UnsupportedEncodingException - If the named encoding is not supported

readEntireFile

public static java.lang.String readEntireFile(java.lang.String fromFile)
                                       throws java.io.IOException
Get all text in a file.

Parameters:
fromFile - Name of file where to get the text.
Returns:
all the text in the File.
Throws:
java.io.IOException

readEntireFile

public static java.lang.String readEntireFile(java.lang.String fromFile,
                                              java.lang.String encoding)
                                       throws java.io.IOException,
                                              java.io.UnsupportedEncodingException
Get all text in a file.

Parameters:
fromFile - Name of file where to get the text.
encoding - name of the encoding to use to translate the bytes in the file into chars e.g. "windows-1252" "UTF-8" "UTF-16"
Returns:
all the text in the File.
Throws:
java.io.IOException
java.io.UnsupportedEncodingException - If the named encoding is not supported

writeEntireFile

public static void writeEntireFile(java.io.File toFile,
                                   java.lang.String text)
                            throws java.io.IOException
Write all the text in a file

Parameters:
toFile - file where to write the text
text - Text to write
Throws:
java.io.IOException

writeEntireFile

public static void writeEntireFile(java.io.File toFile,
                                   java.lang.String text,
                                   java.lang.String encoding)
                            throws java.io.IOException
Write all the text in a file

Parameters:
toFile - file where to write the text
text - Text to write
encoding - name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
Throws:
java.io.IOException
java.io.UnsupportedEncodingException - If the named encoding is not supported

writeEntireFile

public static void writeEntireFile(java.lang.String toFile,
                                   java.lang.String text)
                            throws java.io.IOException
Write all the text in a file

Parameters:
toFile - Name of file where to write the text
text - Text to write
Throws:
java.io.IOException

writeEntireFile

public static void writeEntireFile(java.lang.String toFile,
                                   java.lang.String text,
                                   java.lang.String encoding)
                            throws java.io.IOException
Write all the text in a file

Parameters:
toFile - file where to write the text
text - Text to write
encoding - name of the encoding to use to translate chars to bytes e.g. "windows-1252" "UTF-8" "UTF-16"
Throws:
java.io.IOException
java.io.UnsupportedEncodingException - If the named encoding is not supported