eu.scape_project.xa.tw.util
Class FileUtil

java.lang.Object
  extended by eu.scape_project.xa.tw.util.FileUtil

public final class FileUtil
extends Object

These are generic file utilities used by the client and service.

Version:
0.3
Author:
Thomas Kraemer, shsdev https://github.com/shsdev

Field Summary
static String JAVA_TMP
          The Java property for the system temp directory
 
Method Summary
static void close(Closeable out)
           
static boolean deleteTempFiles(File workFolder)
          This method deletes all the content in a folder, without the need of passing it a PlanetsLogger instance!
static File getSystemTempFolder()
          Get system's JAVA temporary directory.
static File getTmpFile(byte[] data, String name, String suffix)
          Get temporary file
static File getTmpFile(String name, String suffix)
          Get temporary file
static String makePath(String... parts)
           
static boolean mkdir(File file)
           
static boolean mkdirs(File file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_TMP

public static final String JAVA_TMP
The Java property for the system temp directory

Method Detail

getSystemTempFolder

public static File getSystemTempFolder()
Get system's JAVA temporary directory.

Returns:
System's JAVA temporary directory

getTmpFile

public static File getTmpFile(String name,
                              String suffix)
Get temporary file

Parameters:
name - The name to use when generating the temp file
suffix - The suffix for the temp file to be created
Returns:
Returns a temp file created in the System-Temp folder

getTmpFile

public static File getTmpFile(byte[] data,
                              String name,
                              String suffix)
Get temporary file

Parameters:
data - - the data to write to that file
name - - the file name of the file to be created
suffix - - the suffx of that file (e.g. ".tmp", ".bin", ...)
Returns:
- a new File with the given content (--> data), name and extension.

deleteTempFiles

public static boolean deleteTempFiles(File workFolder)
This method deletes all the content in a folder, without the need of passing it a PlanetsLogger instance!

Parameters:
workFolder - the folder you wish to delete. All contained folders will be deleted recursively
Returns:
true, if all folders were deleted and false, if not.

close

public static void close(Closeable out)
Parameters:
out - The closeable (Writer, Stream, etc.) to close

mkdir

public static boolean mkdir(File file)
Parameters:
file - The file to call mkdir on and check for the result
Returns:
The result of calling mkdirs on the given file
Throws:
IllegalArgumentException - if the creation was not successful and the file does not already exist

mkdirs

public static boolean mkdirs(File file)
Parameters:
file - The file to call mkdirs on and check for the result
Returns:
The result of calling mkdirs on the given file
Throws:
IllegalArgumentException - if the creation was not successful and the file does not already exist

makePath

public static String makePath(String... parts)
Parameters:
parts - String args to be assembled into a path.
Returns:
the created path.


Copyright © 2013. All Rights Reserved.