net.sf.statcvs.util
Class FileUtils

java.lang.Object
  extended bynet.sf.statcvs.util.FileUtils

public class FileUtils
extends java.lang.Object

Some helpful file functions

Version:
$Id: FileUtils.java,v 1.15 2003/03/24 19:09:22 cyganiak Exp $
Author:
Lukasz Pekacki

Constructor Summary
FileUtils()
           
 
Method Summary
static void copyFile(java.io.InputStream in, java.io.File out)
          Copy a InputStream into a File
static void copyFile(java.lang.String inputName, java.lang.String destination)
          Copyies a file to a specified desitination
static java.lang.String getAbsoluteName(java.lang.String path, java.lang.String filename)
          Concatenates path and filename to an absolute filename by inserting the system file separator.
static java.lang.String getDefaultDirSeparator()
          Returns the java path seperator
static java.lang.String getDirSeparator()
          Returns the os dependend path seperator
static java.lang.String getFilenameWithDirectory(java.lang.String filename)
          Return the full path to the specified filename
static java.lang.String getFilenameWithoutPath(java.lang.String filename)
          Takes a filename with path and returns just the filename.
static java.lang.String getPathWithoutEndingSlash(java.lang.String path)
          Deletes the ending directory separator of a given path if there is one and returns the result.
 
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

copyFile

public static void copyFile(java.lang.String inputName,
                            java.lang.String destination)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Copyies a file to a specified desitination

Parameters:
inputName - File
destination - Filename
Throws:
java.io.FileNotFoundException - if no input file exists
java.io.IOException - if cannot read or write

copyFile

public static void copyFile(java.io.InputStream in,
                            java.io.File out)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
Copy a InputStream into a File

Parameters:
in - source
out - destination
Throws:
java.io.FileNotFoundException - if not found
java.io.IOException - if read/write error

getFilenameWithDirectory

public static java.lang.String getFilenameWithDirectory(java.lang.String filename)
Return the full path to the specified filename

Parameters:
filename - desired name of file
Returns:
String the full path to the specified filename

getFilenameWithoutPath

public static java.lang.String getFilenameWithoutPath(java.lang.String filename)
Takes a filename with path and returns just the filename.

Parameters:
filename - a filename with path
Returns:
just the filename part

getDirSeparator

public static java.lang.String getDirSeparator()
Returns the os dependend path seperator

Returns:
String os dependend path seperator

getDefaultDirSeparator

public static java.lang.String getDefaultDirSeparator()
Returns the java path seperator

Returns:
String java path seperator

getPathWithoutEndingSlash

public static java.lang.String getPathWithoutEndingSlash(java.lang.String path)
Deletes the ending directory separator of a given path if there is one and returns the result. Otherwise the path is unhandled returned.

The separator is the one used bye the underlying operating system and it is the one returned bye the getDirSeparator() method.

Parameters:
path - The path to delete the directory separator from.
Returns:
The path without the ending directory separator.
See Also:
getDirSeparator()

getAbsoluteName

public static java.lang.String getAbsoluteName(java.lang.String path,
                                               java.lang.String filename)
Concatenates path and filename to an absolute filename by inserting the system file separator.

Parameters:
path - The path to use.
filename - The filename for concatenation.
Returns:
The concatenated absolute filename.