Package net.sf.statcvs.util
Class FileUtils
java.lang.Object
net.sf.statcvs.util.FileUtils
Some helpful file functions
TODO: Remove redundancy, write tests
- Version:
- $Id: FileUtils.java,v 1.21 2009/08/19 22:11:15 benoitx Exp $
- Author:
- Lukasz Pekacki
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyFile(InputStream in, File out) Copy a InputStream into a Filestatic voidCopies a file to a specified destinationstatic StringgetAbsoluteName(String path, String filename) Concatenatespathand filename to an absolute filename by inserting the system file separator.static StringReturns the java path separatorstatic StringgetDirectoryName(String path) Returns the last component of a directory path.static StringReturns the os dependent path separatorstatic StringgetFilenameWithoutPath(String filename) Takes a filename with path and returns just the filename.static StringgetParentDirectoryPath(String path) Returns all but the last component of a directory pathstatic StringDeletes the ending directory separator of a givenpathif there is one and returns the result.static StringreadTextFromURL(String urlTxt) Read a full file into a string.
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
copyFile
public static void copyFile(String inputName, String destination) throws FileNotFoundException, IOException Copies a file to a specified destination- Parameters:
inputName- Filedestination- Filename- Throws:
FileNotFoundException- if no input file existsIOException- if cannot read or write
-
copyFile
Copy a InputStream into a File- Parameters:
in- sourceout- destination- Throws:
FileNotFoundException- if not foundIOException- if read/write error
-
getFilenameWithoutPath
Takes a filename with path and returns just the filename.- Parameters:
filename- a filename with path- Returns:
- just the filename part
-
getDirSeparator
Returns the os dependent path separator- Returns:
- String os dependent path separator
-
getDefaultDirSeparator
Returns the java path separator- Returns:
- String java path separator
-
getPathWithoutEndingSlash
Deletes the ending directory separator of a givenpathif 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- Thepathto delete the directory separator from.- Returns:
- The
pathwithout the ending directory separator. - See Also:
-
getAbsoluteName
Concatenatespathand 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.
-
getDirectoryName
Returns the last component of a directory path.- Parameters:
path- a directory, ending in "/", for example "src/net/sf/statcvs/"- Returns:
- the last component of the path, for example "statcvs"
-
getParentDirectoryPath
Returns all but the last component of a directory path- Parameters:
path- a directory, ending in "/", for example "src/net/sf/statcvs/"- Returns:
- all but the last component of the path, for example "src/net/sf/"
-
readTextFromURL
Read a full file into a string.- Parameters:
urlTxt- URL of the text to get- Returns:
-