ucot.utils
Class FileTools

java.lang.Object
  extended by ucot.utils.FileTools

public class FileTools
extends java.lang.Object

This class contains some operations for file handling.


Field Summary
static java.lang.String FILE_NOT_FOUND
          Message for file not found -situation.
static java.lang.String FILE_NOT_READABLE
          Message for file not readable -situation.
static java.lang.String FILE_NOT_WRITABLE
          Message for file not writable -situation.
static java.lang.String OPERATION_FORBIDDEN
          Message for operation not permited -situation.
 
Constructor Summary
FileTools()
           
 
Method Summary
static java.io.File changeExtension(java.io.File original, java.lang.String extension)
          Changes given file's extension
static void copyFile(java.io.File from, java.io.File to)
          Method copies file.
static void copyFile(java.lang.String from, java.lang.String to)
          Copies file represented by path to target path.
static void copyFile(java.net.URL from, java.net.URL to)
          Copies file represented by url to the the file represented by anaother url.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_NOT_FOUND

public static final java.lang.String FILE_NOT_FOUND
Message for file not found -situation.


FILE_NOT_READABLE

public static final java.lang.String FILE_NOT_READABLE
Message for file not readable -situation.


FILE_NOT_WRITABLE

public static final java.lang.String FILE_NOT_WRITABLE
Message for file not writable -situation.


OPERATION_FORBIDDEN

public static final java.lang.String OPERATION_FORBIDDEN
Message for operation not permited -situation.

Constructor Detail

FileTools

public FileTools()
Method Detail

copyFile

public static void copyFile(java.io.File from,
                            java.io.File to)
                     throws java.io.IOException
Method copies file. It copies from source to target file. If the target file exists its is overwriten. If the target file is direcoty then the source file is copied with its original name under the target directory.

Parameters:
from - The source file to copy from. It must exist.
to - The target file or directory.
Throws:
java.io.IOException

copyFile

public static void copyFile(java.net.URL from,
                            java.net.URL to)
                     throws java.io.IOException
Copies file represented by url to the the file represented by anaother url. Uses copyFile(File,File)-method to perform the actual copy.

Parameters:
from - The URL of source file.
to - The URL of target file or directory.
Throws:
java.io.IOException
See Also:
copyFile(File, File)

copyFile

public static void copyFile(java.lang.String from,
                            java.lang.String to)
                     throws java.io.IOException
Copies file represented by path to target path. Uses copyFile(File,File)-method to perform the actual copy.

Parameters:
from - The path of the source file.
to - The path of the target file or directory.
Throws:
java.io.IOException
See Also:
copyFile(File, File)

changeExtension

public static java.io.File changeExtension(java.io.File original,
                                           java.lang.String extension)
Changes given file's extension

Parameters:
original - original file
extension - new extension for the file
Returns:
file with changed extension