net.sourceforge.jaulp.file
Class FileUtils

java.lang.Object
  extended by net.sourceforge.jaulp.file.FileUtils

public class FileUtils
extends java.lang.Object

Utility class for the use of File object. Most methods are set to deprecated and has gone to the appropriate class.

Version:
1.0
Author:
Asterios Raptis

Constructor Summary
protected FileUtils()
           
 
Method Summary
static boolean copyFile(java.io.File source, java.io.File destination)
          Deprecated. Use instead the method CopyFileUtils.copyFile(source, destination).
static boolean createDirectory(java.io.File dir)
          Deprecated. Use instead the method CreateFileUtils.createDirectory(File).
static boolean createFile(java.io.File file)
          Deprecated. Use instead the method CreateFileUtils.createFile(File).
static byte[] download(java.net.URI uri)
          Downloads Data from the given URI.
static java.lang.String getAbsolutPathWithoutFilename(java.io.File file)
          Gets the absolut path without the filename.
static java.lang.String getCurrentAbsolutPathWithoutDotAndSlash()
          Gets the current absolut path without the dot and slash.
static java.lang.String getFilenamePrefix(java.io.File file)
          Gets the filename with the absolute path prefix.
static java.lang.String getFilenameSuffix(java.io.File file)
          Gets the filename suffix or null if no suffix exists or the given file object is a directory.
static java.lang.String getFilenameWithoutExtension(java.io.File file)
          Gets the filename without the extension or null if the given file object is a directory.
static boolean isOpen(java.io.File file)
          Not yet implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

protected FileUtils()
Method Detail

copyFile

public static boolean copyFile(java.io.File source,
                               java.io.File destination)
                        throws java.io.IOException,
                               FileIsADirectoryException
Deprecated. Use instead the method CopyFileUtils.copyFile(source, destination).

Copys a source file to the destination file.

Parameters:
source - The source file.
destination - The destination file.
Throws:
java.io.IOException - Is thrown if an error occurs by reading or writing.
FileIsADirectoryException - Is thrown if the destination file is a directory.

createDirectory

public static boolean createDirectory(java.io.File dir)
                               throws DirectoryAllreadyExistsException
Deprecated. Use instead the method CreateFileUtils.createDirectory(File).

Creates a new directory.

Parameters:
dir - The directory to create.
Returns:
Returns true if the directory was created otherwise false.
Throws:
DirectoryAllreadyExistsException - Thrown if the directory all ready exists.

createFile

public static boolean createFile(java.io.File file)
                          throws java.io.IOException
Deprecated. Use instead the method CreateFileUtils.createFile(File).

Creates an empty file if the File does not exists otherwise it lets the file as it is.

Parameters:
file - the file.
Returns:
true, if successful.
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

download

public static byte[] download(java.net.URI uri)
Downloads Data from the given URI.

Parameters:
uri - The URI from where to download.
Returns:
Returns a byte array or null.

getAbsolutPathWithoutFilename

public static java.lang.String getAbsolutPathWithoutFilename(java.io.File file)
Gets the absolut path without the filename.

Parameters:
file - the file.
Returns:
's the absolut path without filename.

getCurrentAbsolutPathWithoutDotAndSlash

public static java.lang.String getCurrentAbsolutPathWithoutDotAndSlash()
Gets the current absolut path without the dot and slash.

Returns:
's the current absolut path without the dot and slash.

getFilenamePrefix

public static java.lang.String getFilenamePrefix(java.io.File file)
Gets the filename with the absolute path prefix.

Parameters:
file - the file.
Returns:
the filename prefix.

getFilenameWithoutExtension

public static java.lang.String getFilenameWithoutExtension(java.io.File file)
Gets the filename without the extension or null if the given file object is a directory.

Parameters:
file - the file.
Returns:
the filename without the extension or null if the given file object is a directory.

getFilenameSuffix

public static java.lang.String getFilenameSuffix(java.io.File file)
Gets the filename suffix or null if no suffix exists or the given file object is a directory.

Parameters:
file - the file.
Returns:
's the filename suffix or null if no suffix exists or the given file object is a directory.

isOpen

public static boolean isOpen(java.io.File file)
Not yet implemented. Checks if the given file is open.

Parameters:
file - The file to check.
Returns:
Return true if the file is open otherwise false.


Copyright © 2010. All Rights Reserved.