deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.framework.util
Class FileUtils

java.lang.Object
  extended by org.deegree.framework.util.FileUtils

public class FileUtils
extends Object

the class offeres several static methods for handling file access

Since:
2.0
Version:
$Revision: 18195 $, 1.0. $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
Author:
Andreas Poth, last edited by: $Author: mschneider $

Constructor Summary
FileUtils()
           
 
Method Summary
static void appendsToFile(String fileName, String data)
          appends the passed string to the file identified by the passed name.
static void copy(File from, File to)
          copies a file to another
static StringBuffer readTextFile(File file)
          reads a Text file from its resource.
static StringBuffer readTextFile(InputStream is)
          reads a Text file from its resource.
static StringBuffer readTextFile(Reader reader)
          reads a Text file from its resource.
static StringBuffer readTextFile(URL url)
          reads a Text file from its resource.
static void replace(String oldRegex, String replacement, File inFile, File outFile)
           
static void replace(String oldRegex, String replacement, Reader reader, Writer writer)
          Closes the streams!
static URL resolt(URL rootPath, String url)
          Resolves the given URL (which may be relative) against a rootPath into an URL (which is always absolute).
static void writeToFile(String fileName, String data)
          writes the the passed string to a file created using the passed file name.
static void writeToFile(String fileName, String data, String encoding)
          writes the the passed string to a file created using the passed file name using the defined character encoding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

writeToFile

public static final void writeToFile(String fileName,
                                     String data)
                              throws IOException
writes the the passed string to a file created using the passed file name. For writing to the resource an OutputStreamReader with encoding read from CharsetUtils.getSystemCharset().

Parameters:
fileName -
data -
Throws:
IOException

writeToFile

public static final void writeToFile(String fileName,
                                     String data,
                                     String encoding)
                              throws IOException
writes the the passed string to a file created using the passed file name using the defined character encoding.

Parameters:
fileName -
data -
encoding -
Throws:
IOException

appendsToFile

public static final void appendsToFile(String fileName,
                                       String data)
                                throws IOException
appends the passed string to the file identified by the passed name. If the file does not exist an exception will be thrown.

Parameters:
fileName -
data -
Throws:
IOException

readTextFile

public static StringBuffer readTextFile(File file)
                                 throws IOException
reads a Text file from its resource. For accessing the resource an InputStreamReader with encoding read from CharsetUtils.getSystemCharset()

Parameters:
file -
Returns:
contents of the file as a StringBuffer
Throws:
IOException

readTextFile

public static StringBuffer readTextFile(URL url)
                                 throws IOException
reads a Text file from its resource. For accessing the resource an InputStreamReader with encoding read from CharsetUtils.getSystemCharset()

Parameters:
url -
Returns:
contents of the url as a StringBuffer
Throws:
IOException

readTextFile

public static StringBuffer readTextFile(InputStream is)
                                 throws IOException
reads a Text file from its resource. For accessing the resource an InputStreamReader with encoding read from CharsetUtils.getSystemCharset()

Parameters:
is -
Returns:
contents of the input stream as a StringBuffer
Throws:
IOException

readTextFile

public static StringBuffer readTextFile(Reader reader)
                                 throws IOException
reads a Text file from its resource.

Parameters:
reader -
Returns:
contents of the reader as a StringBuffer
Throws:
IOException

copy

public static void copy(File from,
                        File to)
                 throws IOException
copies a file to another

Parameters:
from -
to -
Throws:
IOException

replace

public static void replace(String oldRegex,
                           String replacement,
                           File inFile,
                           File outFile)
                    throws IOException
Parameters:
oldRegex -
replacement -
inFile - file.encoding encoded text file
outFile - file.encoding encoded text file
Throws:
IOException

replace

public static void replace(String oldRegex,
                           String replacement,
                           Reader reader,
                           Writer writer)
                    throws IOException
Closes the streams!

Parameters:
oldRegex -
replacement -
reader -
writer -
Throws:
IOException

resolt

public static final URL resolt(URL rootPath,
                               String url)
                        throws MalformedURLException
Resolves the given URL (which may be relative) against a rootPath into an URL (which is always absolute).

Parameters:
rootPath -
url -
Returns:
the resolved URL object
Throws:
MalformedURLException

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org