jd.io
Class FileUtil

java.lang.Object
  extended byjd.io.FileUtil

public abstract class FileUtil
extends Object

A collection of utility function for I/O access.


Constructor Summary
FileUtil()
           
 
Method Summary
static void close(InputStream in)
          Close an InputStream and catch any thrown IOException.
static void close(OutputStream out)
          Close an OutputStream and catch any thrown IOException.
static void close(Reader reader)
          Close a Reader and catch any thrown IOException.
static void close(Writer writer)
          Close a Writer and catch any thrown IOException.
static void copy(File srcfile, File destfile)
          Copy all data from an File to another File.
static void copy(InputStream src, OutputStream dest)
          Copy all data from an InputStream to an OutputStream.
static void copy(InputStream src, StringBuffer s)
          Copy the data from src to the destination StringBuffer.
static void copy(Reader src, StringBuffer s)
          Copy the data from src to the destination StringBuffer.
static void copy(Reader src, Writer dest)
          Copy all data from a Reader to a Writer.
static void deleteDirectoryContent(File directory, boolean recursive)
          Delete all files of a directory.
static void deleteDirectoryTree(File directory)
          Delete a directory with all files and subdirectories.
static Object deserialize(byte[] array)
           
static String getExtension(File file)
          Return the extension of a file name.
static String getExtension(String filename)
          Return the extension of a file name.
static String getFileName(File file)
          Return the name of a file without the extension.
static String getLineSeparator()
           
static String read(File srcfile)
          Read the data from src.
static String read(InputStream src)
          Copy the data from src to the destination StringBuffer.
static String read(Reader src)
          Read the data from src.
static String[] readLines(InputStream in)
          Read the lines from an InputStream.
static String[] readLines(InputStream in, boolean trim)
          Read the lines from an InputStream.
static byte[] serialize(Serializable object)
           
 
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

close

public static void close(InputStream in)
Close an InputStream and catch any thrown IOException.


close

public static void close(OutputStream out)
Close an OutputStream and catch any thrown IOException.


close

public static void close(Writer writer)
Close a Writer and catch any thrown IOException.


close

public static void close(Reader reader)
Close a Reader and catch any thrown IOException.


copy

public static void copy(Reader src,
                        Writer dest)
                 throws IOException
Copy all data from a Reader to a Writer.

Throws:
IOException - if an I/O error occurs

copy

public static void copy(InputStream src,
                        OutputStream dest)
                 throws IOException
Copy all data from an InputStream to an OutputStream.

Throws:
IOException - if an I/O error occurs

copy

public static void copy(File srcfile,
                        File destfile)
                 throws IOException
Copy all data from an File to another File.

Throws:
IOException - if an I/O error occurs

copy

public static void copy(Reader src,
                        StringBuffer s)
                 throws IOException
Copy the data from src to the destination StringBuffer.

Throws:
IOException - if an I/O error occurs

copy

public static void copy(InputStream src,
                        StringBuffer s)
                 throws IOException
Copy the data from src to the destination StringBuffer.

Throws:
IOException - if an I/O error occurs

read

public static String read(InputStream src)
                   throws IOException
Copy the data from src to the destination StringBuffer.

Throws:
IOException - if an I/O error occurs

read

public static String read(Reader src)
                   throws IOException
Read the data from src.

Throws:
IOException - if an I/O error occurs

read

public static String read(File srcfile)
                   throws IOException
Read the data from src.

Throws:
IOException - if an I/O error occurs

readLines

public static String[] readLines(InputStream in)
                          throws IOException
Read the lines from an InputStream.

Throws:
IOException - if an I/O error occurs

readLines

public static String[] readLines(InputStream in,
                                 boolean trim)
                          throws IOException
Read the lines from an InputStream.

Throws:
IOException - if an I/O error occurs

getExtension

public static String getExtension(File file)
Return the extension of a file name.


getExtension

public static String getExtension(String filename)
Return the extension of a file name. The extension contains all characters of the name after the last dot.

Returns:
the extension or an zero-length string if the name has no extension

getFileName

public static String getFileName(File file)
Return the name of a file without the extension.


deleteDirectoryTree

public static void deleteDirectoryTree(File directory)
                                throws IOException
Delete a directory with all files and subdirectories.

Throws:
IOException - if a file can not be deleted.

deleteDirectoryContent

public static void deleteDirectoryContent(File directory,
                                          boolean recursive)
                                   throws IOException
Delete all files of a directory. The directory itself is not deleted.

Parameters:
directory - a directory
Throws:
IOException - if a file can not be deleted.

serialize

public static byte[] serialize(Serializable object)
                        throws IOException
Throws:
IOException

deserialize

public static Object deserialize(byte[] array)
                          throws IOException,
                                 ClassNotFoundException
Throws:
IOException
ClassNotFoundException

getLineSeparator

public static String getLineSeparator()