Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.common
Class TLptsFileUtil

java.lang.Object
  extended by com.lapetus_ltd.api.common.TLptsFileUtil

public class TLptsFileUtil
extends java.lang.Object

Class Description : This is the class for file and directory operations.

Use this class to perform simple, but useful functions on directories and files.

$LastChangedRevision: 1175 $
$LastChangedDate:: 2010-11-09 13:47:26#$


Method Summary
static java.lang.String createDirectoryPath(java.lang.String path)
          Creates a new Directory.
static java.lang.String getCurrentDirectory()
          Gets the folder that the application is running in.
static java.lang.String getCurrentParentDirectory()
          Gets the parent of the folder that the application is running in.
static java.util.List<java.lang.String> getFileList(java.lang.String dir, java.lang.String extension, boolean isGetFullPath)
          This function gets all the files of the specified type in all sub directories.
static java.lang.String getJavaHome()
          Gets the Java Home directory.
static java.lang.String getUserHomeDirectory()
          Gets the users home directory, where the Java RT always has rights to access data.
static java.lang.String getUserHomeLapetusDirectory()
          Gets the users home directory and puts lapetus as a sub-directory on the end of it.
static boolean isPath(java.lang.String path)
          Checks to see if the path (directory of file) exists.
static void zI()
          Obfuscated, as it is not required by the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createDirectoryPath

public static java.lang.String createDirectoryPath(java.lang.String path)
Creates a new Directory.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : Set the full path name of the directory you want to create.

Example :

 // Method is going to create directory 'Projects' in /home/Documents/ path
 String dir =  createDirectoryPath(/home/Documents/Projects/)
 System.out.println(dir);
 Result : /home/Documents/Projects/
 

Parameters:
path - the full path name of the directory to create.
Returns:
the full path name of the created directory or an empty string on error. The logger will contain an error TLptsLogger

getCurrentDirectory

public static java.lang.String getCurrentDirectory()
Gets the folder that the application is running in.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 String dir = TLptsFileUtil.getCurrentDirectory();
 System.out.println(dir);
 Result : /home/db_japi/
 

Returns:
Returns the application's home path with the "/" on the end

getCurrentParentDirectory

public static java.lang.String getCurrentParentDirectory()
Gets the parent of the folder that the application is running in.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 String dir = TLptsFileUtil.getCurrentParentDirectory();
 System.out.println(dir);
 Result : /home/ and Current Directory is: /home/db_japi/
 

Returns:
Returns the path with the "/" on the end

getFileList

public static java.util.List<java.lang.String> getFileList(java.lang.String dir,
                                                           java.lang.String extension,
                                                           boolean isGetFullPath)
This function gets all the files of the specified type in all sub directories.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 Lets pretend we have the following directories and files:
 /dir1/dir2/file.ext1
 /dir1/dir3/file.ext2
 c:\dir1\dir4\file.ext1     ( '\' is changed to '/' for consistency)
 /dir2/dir6/file1.ext4

 getFileList("/dir1","ext1",true) returns /dir1/dir2/file.ext1 and c:/dir1/dir4/file.ext1
 getFileList("/dir2","ext4",false) returns dir6/file1.ext4
 

Parameters:
dir - The directory to start looking in for all files and sub-directories
extension - The extension filter type. Put "" for all files or "EXT" without the period ".".
isGetFullPath - Returns the full path of the files in the list.
Returns:
Returns the list of all files, with their relative or full paths.

getJavaHome

public static java.lang.String getJavaHome()
Gets the Java Home directory.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : The same as the JAVA_HOME environment variable.
This may be under the JDK directory.

Example :

 String dir = TLptsFileUtil.getJavaHome();
 System.out.println(dir);
 Result : /Java/jdk1.6.0_10/jre
 

Returns:
The path to the java home directory.
There is always a slash on the end of this path "/".
All \ characters are converted to /.

getUserHomeDirectory

public static java.lang.String getUserHomeDirectory()
Gets the users home directory, where the Java RT always has rights to access data.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : Use this directory to store information, without worrying about security rights.

Example :

 String dir = TLptsFileUtil.getUserHomeDirectory();
 System.out.println(dir);
 Result : /home/user/ or c:/Users/me/
 

Returns:
The path to the home directory of the currently logged user.
There is always a slash on the end of this path "/".
All \ characters are converted to /.

getUserHomeLapetusDirectory

public static java.lang.String getUserHomeLapetusDirectory()
Gets the users home directory and puts lapetus as a sub-directory on the end of it.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes : Use this directory to store information, without worrying about security rights.

The lapetus sub-directory is always in lowercase.

If the directory does not exist it is created on the first call to this function.

Example :

 String dir = TLptsFileUtil.getUserHomeLapetusDirectory();
 System.out.println(dir);
 Result : /home/user/.lapetus-ltd/ or c:/Users/me/.lapetus-ltd/
 

Returns:
The path to the lapetus sub-directly of the home directory of the currently logged user.
There is always a slash on the end of this path "/".
All \ characters are converted to /.

isPath

public static boolean isPath(java.lang.String path)
Checks to see if the path (directory of file) exists.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :

 boolean doesPathExist = TLptsFileUtil.isPath(fileName);
 if (doesPathExist)
  System.out.println(FileName + " exists.");
 else
  System.out.println(FileName + " does not exist.");
 

Parameters:
path - The path (file or dirtory) to verify for existence.
Returns:
true if the path exists, false otherwise.

zI

public static void zI()
Obfuscated, as it is not required by the application.



Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)