org.eparapher.core.tools
Class FileUtil

java.lang.Object
  extended by org.eparapher.core.tools.FileUtil

public class FileUtil
extends Object

Work with files in file system (delete, get size, etc...).

Version:
$Revision: 1.11 $ $Date: 2002/05/02 14:41:53 $
Author:
Alexander Feldman (updated by $Author: feldman $)

Constructor Summary
FileUtil()
           
 
Method Summary
protected static void close(InputStream iStream, OutputStream oStream)
          Closes InputStream and/or OutputStream.
static boolean fileEmpty(String fileName)
           
static boolean fileExists(String fileName)
           
static byte[] readFile(String fileName)
           
static void writeToFile(String fileName, byte[] data)
           
static void writeToFile(String fileName, InputStream iStream)
          Calls writeToFile with createDir flag false.
static void writeToFile(String fileName, InputStream iStream, boolean createDir)
          Writes InputStream to a given fileName.
 
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

writeToFile

public static void writeToFile(String fileName,
                               InputStream iStream)
                        throws IOException
Calls writeToFile with createDir flag false.

Throws:
IOException
See Also:
writeToFile(String fileName, InputStream iStream, boolean createDir)

writeToFile

public static void writeToFile(String fileName,
                               InputStream iStream,
                               boolean createDir)
                        throws IOException
Writes InputStream to a given fileName. And, if directory for this file does not exists, if createDir is true, creates it, otherwice throws OMDIOexception.

Parameters:
fileName - - filename save to.
iStream - - InputStream with data to read from.
createDir - (false by default)
Throws:
IOException - in case of any error.

writeToFile

public static void writeToFile(String fileName,
                               byte[] data)
                        throws IOException
Throws:
IOException

close

protected static void close(InputStream iStream,
                            OutputStream oStream)
                     throws IOException
Closes InputStream and/or OutputStream. It makes sure that both streams tried to be closed, even first throws an exception.

Throws:
IOException

fileExists

public static boolean fileExists(String fileName)

fileEmpty

public static boolean fileEmpty(String fileName)

readFile

public static byte[] readFile(String fileName)
                       throws IOException
Throws:
IOException


Copyright © 2009 eParapher Software Foundation. All Rights Reserved.