deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.framework.util
Class FileUtils

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

public class FileUtils
extends java.lang.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(java.lang.String fileName, java.lang.String data)
          appends the passed string to the file identified by the passed name.
static void copy(java.io.File from, java.io.File to)
          copies a file to another
static java.lang.StringBuffer readTextFile(java.io.File file)
          reads a Text file from its resource.
static java.lang.StringBuffer readTextFile(java.io.InputStream is)
          reads a Text file from its resource.
static java.lang.StringBuffer readTextFile(java.io.Reader reader)
          reads a Text file from its resource.
static java.lang.StringBuffer readTextFile(java.net.URL url)
          reads a Text file from its resource.
static void replace(java.lang.String oldRegex, java.lang.String replacement, java.io.File inFile, java.io.File outFile)
           
static void replace(java.lang.String oldRegex, java.lang.String replacement, java.io.Reader reader, java.io.Writer writer)
          Closes the streams!
static java.net.URL resolt(java.net.URL rootPath, java.lang.String url)
          Resolves the given URL (which may be relative) against a rootPath into an URL (which is always absolute).
static void writeToFile(java.lang.String fileName, java.lang.String data)
          writes the the passed string to a file created using the passed file name.
static void writeToFile(java.lang.String fileName, java.lang.String data, java.lang.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(java.lang.String fileName,
                                     java.lang.String data)
                              throws java.io.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:
java.io.IOException

writeToFile

public static final void writeToFile(java.lang.String fileName,
                                     java.lang.String data,
                                     java.lang.String encoding)
                              throws java.io.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:
java.io.IOException

appendsToFile

public static final void appendsToFile(java.lang.String fileName,
                                       java.lang.String data)
                                throws java.io.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:
java.io.IOException

readTextFile

public static java.lang.StringBuffer readTextFile(java.io.File file)
                                           throws java.io.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:
java.io.IOException

readTextFile

public static java.lang.StringBuffer readTextFile(java.net.URL url)
                                           throws java.io.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:
java.io.IOException

readTextFile

public static java.lang.StringBuffer readTextFile(java.io.InputStream is)
                                           throws java.io.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:
java.io.IOException

readTextFile

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

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

copy

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

Parameters:
from -
to -
Throws:
java.io.IOException

replace

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

replace

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

Parameters:
oldRegex -
replacement -
reader -
writer -
Throws:
java.io.IOException

resolt

public static final java.net.URL resolt(java.net.URL rootPath,
                                        java.lang.String url)
                                 throws java.net.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:
java.net.MalformedURLException

deegree 2.5 (2011/06/29 09:44 build-8-official)

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