net.sf.statcvs.util
Class FileUtils
Some helpful file functions
TODO: Remove redundancy, write tests
$Id: FileUtils.java,v 1.20 2008/04/02 11:52:02 benoitx Exp $static void | copyFile(InputStream in, File out) - Copy a InputStream into a File
|
static void | copyFile(String inputName, String destination) - Copyies a file to a specified desitination
|
static String | getAbsoluteName(String path, String filename) - Concatenates
path and filename to an
absolute filename by inserting the system file separator.
|
static String | getDefaultDirSeparator() - Returns the java path seperator
|
static String | getDirSeparator() - Returns the os dependend path seperator
|
static String | getDirectoryName(String path) - Returns the last compontent of a directory path.
|
static String | getFilenameWithoutPath(String filename) - Takes a filename with path and returns just the filename.
|
static String | getParentDirectoryPath(String path) - Returns all but the last compontent of a directory path
|
static String | getPathWithoutEndingSlash(String path) - Deletes the ending directory separator of a
given
path if there is one and returns
the result.
|
copyFile
public static void copyFile(InputStream in,
File out)
throws FileNotFoundException,
IOException
Copy a InputStream into a File
in
- sourceout
- destination
copyFile
public static void copyFile(String inputName,
String destination)
throws FileNotFoundException,
IOException
Copyies a file to a specified desitination
inputName
- Filedestination
- Filename
getAbsoluteName
public static String getAbsoluteName(String path,
String filename)
Concatenates path
and filename to an
absolute filename by inserting the system file separator.
path
- The path to use.filename
- The filename for concatenation.
- The concatenated absolute filename.
getDefaultDirSeparator
public static String getDefaultDirSeparator()
Returns the java path seperator
- String java path seperator
getDirSeparator
public static String getDirSeparator()
Returns the os dependend path seperator
- String os dependend path seperator
getDirectoryName
public static String getDirectoryName(String path)
Returns the last compontent of a directory path.
path
- a directory, ending in "/", for example "src/net/sf/statcvs/"
- the last component of the path, for example "statcvs"
getFilenameWithoutPath
public static String getFilenameWithoutPath(String filename)
Takes a filename with path and returns just the filename.
filename
- a filename with path
getParentDirectoryPath
public static String getParentDirectoryPath(String path)
Returns all but the last compontent of a directory path
path
- a directory, ending in "/", for example "src/net/sf/statcvs/"
- all but the last component of the path, for example "src/net/sf/"
getPathWithoutEndingSlash
public static String getPathWithoutEndingSlash(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.
path
- The path
to delete the directory
separator from.
- The
path
without the ending
directory separator.