jodd.file
Class FileUtil

java.lang.Object
  extended byjodd.file.FileUtil

public final class FileUtil
extends java.lang.Object

File utilities.


Field Summary
static int FILE_BUFFER_SIZE
          Buffer size (32KB) for file manipulation methods.
static int OBJECT_BUFFER_SIZE
          Buffer size (32KB) for object serialization methods.
static int STRING_BUFFER_SIZE
          Buffer size (32KB) for file string methods.
 
Constructor Summary
FileUtil()
           
 
Method Summary
static void copy(java.io.File fileIn, java.io.File fileOut)
          Copies one file to another.
static void copy(java.io.File fileIn, java.io.File fileOut, int bufsize)
          Copies one file to another with specified buffer size.
static void copy(java.lang.String fileIn, java.lang.String fileOut)
          Copies one file to another.
static void copy(java.lang.String fileIn, java.lang.String fileOut, int bufsize)
          Copies one file to another with specified buffer size.
static byte[] readBytes(java.io.File file)
          Reads file content as byte array.
static byte[] readBytes(java.lang.String s)
          Reads file content as byte array.
static java.lang.Object readObject(java.lang.String f)
          Reads seralized object from the file.
static java.lang.Object readObject(java.lang.String f, int bufferSize)
          Reads seralized object from the file with specified buffer size
static java.lang.String readString(java.io.File file)
          Reads file's content into a String.
static java.lang.String readString(java.io.File file, int bufferSize)
          Reads file's content into a String.
static java.lang.String readString(java.io.File file, int bufferSize, java.lang.String encoding)
          Reads file's content into a String.
static java.lang.String readString(java.io.File file, java.lang.String encoding)
          Reads file's content into a String.
static java.lang.String readString(java.lang.String fileName)
          Reads file's content into a String.
static java.lang.String readString(java.lang.String fileName, int bufferSize)
          Reads file's content into a String.
static java.lang.String readString(java.lang.String fileName, int bufferSize, java.lang.String encoding)
          Reads file's content into a String.
static java.lang.String readString(java.lang.String fileName, java.lang.String encoding)
          Reads file's content into a String.
static void writeBytes(java.io.File file, byte[] source)
           
static void writeBytes(java.io.File file, byte[] source, int offset, int len)
           
static void writeBytes(java.lang.String filename, byte[] source)
           
static void writeBytes(java.lang.String filename, byte[] source, int offset, int len)
           
static void writeObject(java.lang.String f, java.lang.Object o)
          Writes serializable object to a file.
static void writeObject(java.lang.String f, java.lang.Object o, int bufferSize)
          Writes serializable object to a file with specified buffer size.
static void writeString(java.io.File file, java.lang.String s)
          Writes string to a file.
static void writeString(java.io.File file, java.lang.String s, int bufferSize)
          Writes string to a file.
static void writeString(java.io.File file, java.lang.String s, int bufferSize, java.lang.String encoding)
          Writes string to a file.
static void writeString(java.io.File file, java.lang.String s, java.lang.String encoding)
          Writes string to a file.
static void writeString(java.lang.String fileName, java.lang.String s)
          Writes string to a file.
static void writeString(java.lang.String fileName, java.lang.String s, int bufferSize)
          Writes string to a file.
static void writeString(java.lang.String fileName, java.lang.String s, int bufferSize, java.lang.String encoding)
          Writes string to a file.
static void writeString(java.lang.String fileName, java.lang.String s, java.lang.String encoding)
          Writes string to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_BUFFER_SIZE

public static int FILE_BUFFER_SIZE
Buffer size (32KB) for file manipulation methods.


STRING_BUFFER_SIZE

public static int STRING_BUFFER_SIZE
Buffer size (32KB) for file string methods.


OBJECT_BUFFER_SIZE

public static int OBJECT_BUFFER_SIZE
Buffer size (32KB) for object serialization methods.

Constructor Detail

FileUtil

public FileUtil()
Method Detail

copy

public static void copy(java.lang.String fileIn,
                        java.lang.String fileOut)
                 throws java.io.IOException
Copies one file to another. Existing file will be overwritten,

Parameters:
fileIn - input file
fileOut - output file
Throws:
java.io.IOException

copy

public static void copy(java.lang.String fileIn,
                        java.lang.String fileOut,
                        int bufsize)
                 throws java.io.IOException
Copies one file to another with specified buffer size. Existing file will be overwritten,

Parameters:
fileIn - input file
fileOut - output file
bufsize - size of the buffer used for copying
Throws:
java.io.IOException

copy

public static void copy(java.io.File fileIn,
                        java.io.File fileOut)
                 throws java.io.IOException
Copies one file to another. Existing file will be overwritten,

Parameters:
fileIn - input file
fileOut - output file
Throws:
java.io.IOException

copy

public static void copy(java.io.File fileIn,
                        java.io.File fileOut,
                        int bufsize)
                 throws java.io.IOException
Copies one file to another with specified buffer size. Existing file will be overwritten,

Parameters:
fileIn - input file
fileOut - output file
bufsize - size of the buffer used for copying
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String fileName)
                                   throws java.io.IOException
Reads file's content into a String. Implicitly assumes that the file is in the default encoding.

Parameters:
fileName - name of the file to read from
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String fileName,
                                          int bufferSize)
                                   throws java.io.IOException
Reads file's content into a String. Implicitly assumes that the file is in the default encoding.

Parameters:
fileName - name of the file to read from
bufferSize - buffer size
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File file)
                                   throws java.io.IOException
Reads file's content into a String. Implicitly assumes that the file is in the default encoding.

Parameters:
file - file to read
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File file,
                                          int bufferSize)
                                   throws java.io.IOException
Reads file's content into a String. Implicitly assumes that the file is in the default encoding.

Parameters:
file - file to read
bufferSize - buffer size
Returns:
string with file content or null
Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String fileName,
                               java.lang.String s)
                        throws java.io.IOException
Writes string to a file. Implicitly assumes that the file will be written the default encoding.

Parameters:
fileName - name of the destination file
s - source string
Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String fileName,
                               java.lang.String s,
                               int bufferSize)
                        throws java.io.IOException
Writes string to a file. Implicitly assumes that the file will be written the default encoding.

Parameters:
fileName - name of the destination file
s - source string
bufferSize - buffer size
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File file,
                               java.lang.String s)
                        throws java.io.IOException
Writes string to a file. Implicitly assumes that the file will be written the default encoding.

Parameters:
file - destination file
s - source string
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File file,
                               java.lang.String s,
                               int bufferSize)
                        throws java.io.IOException
Writes string to a file. Implicitly assumes that the file will be written the default encoding.

Parameters:
file - destination file
s - source string
bufferSize - buffer size
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String fileName,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Reads file's content into a String.

Parameters:
fileName - source file name
encoding - java encoding string
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.lang.String fileName,
                                          int bufferSize,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Reads file's content into a String.

Parameters:
fileName - source file name
bufferSize - buffer size
encoding - java encoding string
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File file,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Reads file's content into a String.

Parameters:
file - source file
encoding - java encoding string
Returns:
string with file content or null
Throws:
java.io.IOException

readString

public static java.lang.String readString(java.io.File file,
                                          int bufferSize,
                                          java.lang.String encoding)
                                   throws java.io.IOException
Reads file's content into a String. This is a bit different implementation than other readString() method, since the number of characters in the file is not known. This currently only affest the value of the maximum file size.

Parameters:
file - source file
bufferSize - buffer size
encoding - java encoding string
Returns:
string with file content or null
Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String fileName,
                               java.lang.String s,
                               java.lang.String encoding)
                        throws java.io.IOException
Writes string to a file.

Parameters:
fileName - destination file name
s - source string
encoding - java encoding string
Throws:
java.io.IOException

writeString

public static void writeString(java.lang.String fileName,
                               java.lang.String s,
                               int bufferSize,
                               java.lang.String encoding)
                        throws java.io.IOException
Writes string to a file.

Parameters:
fileName - destination file name
s - source string
bufferSize - buffer size
encoding - java encoding string
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File file,
                               java.lang.String s,
                               java.lang.String encoding)
                        throws java.io.IOException
Writes string to a file.

Parameters:
file - destination file
s - source string
encoding - java encoding string
Throws:
java.io.IOException

writeString

public static void writeString(java.io.File file,
                               java.lang.String s,
                               int bufferSize,
                               java.lang.String encoding)
                        throws java.io.IOException
Writes string to a file.

Parameters:
file - destination file
s - source string
bufferSize - buffer size
encoding - java encoding string
Throws:
java.io.IOException

writeObject

public static void writeObject(java.lang.String f,
                               java.lang.Object o)
                        throws java.io.IOException
Writes serializable object to a file. Existing file will be overwritten.

Parameters:
f - name of the destination file
o - object to write
Throws:
java.io.IOException

writeObject

public static void writeObject(java.lang.String f,
                               java.lang.Object o,
                               int bufferSize)
                        throws java.io.IOException
Writes serializable object to a file with specified buffer size. Existing file will be overwritten.

Parameters:
f - name of the destination file
o - object to write
bufferSize - buffer size used for writing
Throws:
java.io.IOException

readObject

public static java.lang.Object readObject(java.lang.String f)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException,
                                          java.io.FileNotFoundException
Reads seralized object from the file.

Parameters:
f - name of the source file
Returns:
serialized object from the file.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
java.io.FileNotFoundException

readObject

public static java.lang.Object readObject(java.lang.String f,
                                          int bufferSize)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException,
                                          java.io.FileNotFoundException
Reads seralized object from the file with specified buffer size

Parameters:
f - name of the source file
bufferSize - size of buffer used for reading
Returns:
serialized object from the file.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
java.io.FileNotFoundException

readBytes

public static final byte[] readBytes(java.lang.String s)
                              throws java.io.IOException
Reads file content as byte array.

Parameters:
s - file name
Returns:
file content
Throws:
java.io.IOException

readBytes

public static final byte[] readBytes(java.io.File file)
                              throws java.io.IOException
Reads file content as byte array.

Parameters:
file - file to read
Returns:
file content
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.lang.String filename,
                              byte[] source)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.io.File file,
                              byte[] source)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.lang.String filename,
                              byte[] source,
                              int offset,
                              int len)
                       throws java.io.IOException
Throws:
java.io.IOException

writeBytes

public static void writeBytes(java.io.File file,
                              byte[] source,
                              int offset,
                              int len)
                       throws java.io.IOException
Throws:
java.io.IOException


Jodd v0.24.5 Javadoc