Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

com.gentleware.services.util

Class Files

com.gentleware.services.util.Files

public class Files


This class offers a number of utility operations for handling of files.


 Attribute Summary
public static int  FILTER_CONTAINED
 
public static int  FILTER_END
 
public static int  FILTER_START
 
arrow_up
 

 Method Summary
public static File   checkExistenceOrCreateFolder(String absolutePath)
Checks if the given path denotes an existing folder. 
public static boolean   checkFolderExistence(String absolutePath, boolean shouldTestWritable)
Checks if the given path points to an existing folder. 
public static void   clearDirectory(File directory, boolean recursive)
Removes all files in the given directory. 
public static void   close(InputStream inputStream)
 
public static void   close(OutputStream inputStream)
 
public static void   copyFileContent(File source, File target)
Copies the content of one file to another. 
public static File   createFolder(String absolutePath)
Creates the given path as a folder. 
public static File   createTempDir(String prefix, String postfix)
 
public static void   deleteMatchingFiles(File directory, String filter, int filterPosition, boolean recursive)
 
public static File   getCanonicalFile(File file)
 
public static String   getCanonicalPath(String fileName)
Returns the canonical pathname for a given file name. 
public static String   getSuffix(File file)
 
public static String   getSuffix(String filename)
 
public static boolean   isContained(File file, File directory, boolean deep)
Returns true, if the given file is contained in the given directory or in any sub directory  
private static boolean   matchesFilter(File file, String filter, int filterPosition)
 
public static String   readAsciiTextFile(File file)
Reads a file in ISO-8859-15 encoding (which strictly speaking is a superset of ASCII). 
public static byte[]   readFile(File file)
 
public static final byte[]   readInputStream(InputStream is)
Read an input stream until eof is encountered and return the raw bytes. 
public static byte[]   readStream(InputStream inputStream)
 
public static String   readString(InputStream inputStream, String charsetName)
Read a string from an input stream in a specified encoding (may be null to specify the platforms default encoding). 
public static String   readString(InputStream inputStream, String charsetName, int maxLen)
 
public static String   readStringFromUrl(URL url, int maxLen)
 
public static String   readStringFromUrl(URL url, String charsetName, int maxLen)
 
public static String   readTextFile(File file)
Read a text file encoded in the platforms default encoding and return the result. 
public static String   readTextFile(File file, String charsetName)
 
public static String   readUtf8TextFile(File file)
Reads a file in UTF-8 encoding. 
public static void   writeFile(File file, byte[] bytes)
 
arrow_up
 

Tagged Values
static false
 

 Attribute Detail

FILTER_CONTAINED

public static int FILTER_CONTAINED

arrow_up


FILTER_END

public static int FILTER_END

arrow_up


FILTER_START

public static int FILTER_START

arrow_up
 Method Detail

checkExistenceOrCreateFolder

public static File checkExistenceOrCreateFolder(String absolutePath)


Checks if the given path denotes an existing folder. If the path does not exist, the operation tries to create it as folder.  
Parameters:
absolutePath - The absolute path to the folder to be checked or created.
Returns:
A file object pointing to the folder or null, if the given path does not denote a folder or creating it fails for some reason
Since:
2.4
arrow_up


checkFolderExistence

public static boolean checkFolderExistence(String absolutePath, boolean shouldTestWritable)


Checks if the given path points to an existing folder.  
Parameters:
absolutePath - The path to check.
shouldTestWritable -
Returns:
True, if the path points to an existing folder, otherwise false.
Since:
2.4
arrow_up


clearDirectory

public static void clearDirectory(File directory, boolean recursive)


Removes all files in the given directory. Directories that allow no write access can not be cleared.  
Parameters:
directory - The directory to remove all files from.
recursive - Indicates if nested directories should be cleared and removed as well.
Since:
2.2.1
arrow_up


close

public static void close(InputStream inputStream)

Parameters:
inputStream -
arrow_up


close

public static void close(OutputStream inputStream)

Parameters:
inputStream -
arrow_up


copyFileContent

public static void copyFileContent(File source, File target)


Copies the content of one file to another. The target file's content will be removed. Both files have to exist before this operation can be called.  
Parameters:
source - The source file. Has to be a valid and existing file.
target - The target file. Has to be a valid and existing file.
arrow_up


createFolder

public static File createFolder(String absolutePath)


Creates the given path as a folder. Any missing parent directory will be created as well.  
Parameters:
absolutePath - The path to create a folder from.
Returns:
A file object pointing to the newly created folder or null, if the folder cannot be created for some reason.
Since:
2.4
arrow_up


createTempDir

public static File createTempDir(String prefix, String postfix)

Parameters:
prefix - a prefix for the new directory's name - must be at least three chars long
postfix - a postfix for the new directory's name - ".tmp" is used if this is null
Returns:
a new, empty directory that will automatically be deleted on exit
arrow_up


deleteMatchingFiles

public static void deleteMatchingFiles(File directory, String filter, int filterPosition, boolean recursive)

Parameters:
directory -
filter -
filterPosition -
recursive -
arrow_up


getCanonicalFile

public static File getCanonicalFile(File file)

Parameters:
file -
Returns:
arrow_up


getCanonicalPath

public static String getCanonicalPath(String fileName)


Returns the canonical pathname for a given file name. If an IO Exception occurs, the fileName is returned unchanged.  
Parameters:
fileName -
Returns:
arrow_up


getSuffix

public static String getSuffix(File file)

Parameters:
file -
Returns:
arrow_up


getSuffix

public static String getSuffix(String filename)

Parameters:
filename -
Returns:
arrow_up


isContained

public static boolean isContained(File file, File directory, boolean deep)


Returns true, if the given file is contained in the given directory or in any sub directory  
Parameters:
file -
directory - The root directory to search in
deep - Including all sub directories
Returns:
arrow_up


matchesFilter

private static boolean matchesFilter(File file, String filter, int filterPosition)

Parameters:
file -
filter -
filterPosition -
Returns:
arrow_up


readAsciiTextFile

public static String readAsciiTextFile(File file)


Reads a file in ISO-8859-15 encoding (which strictly speaking is a superset of ASCII).  
Parameters:
file -
Returns:
arrow_up


readFile

public static byte[] readFile(File file)

Parameters:
file -
Returns:
arrow_up


readInputStream

public static final byte[] readInputStream(InputStream is)


Read an input stream until eof is encountered and return the raw bytes.  
Parameters:
is -
Returns:
arrow_up


readStream

public static byte[] readStream(InputStream inputStream)

Parameters:
inputStream -
Returns:
arrow_up


readString

public static String readString(InputStream inputStream, String charsetName)


Read a string from an input stream in a specified encoding (may be null to specify the platforms default encoding).  
Parameters:
inputStream -
charsetName -
Returns:
arrow_up


readString

public static String readString(InputStream inputStream, String charsetName, int maxLen)

Parameters:
inputStream -
charsetName -
maxLen -
Returns:
arrow_up


readStringFromUrl

public static String readStringFromUrl(URL url, int maxLen)

Parameters:
url -
maxLen -
Returns:
arrow_up


readStringFromUrl

public static String readStringFromUrl(URL url, String charsetName, int maxLen)

Parameters:
url -
charsetName -
maxLen -
Returns:
arrow_up


readTextFile

public static String readTextFile(File file)

Deprecated.
use one of readUtf8TextFile(), readAsciiTextFile() or readTextFile(File, String charsetName) and handle exception yourself

Read a text file encoded in the platforms default encoding and return the result.  
Parameters:
file - The file that should be read.
Returns:
The contents of the file as string or null if an exception occured.
Since:
2.3
arrow_up


readTextFile

public static String readTextFile(File file, String charsetName)

Parameters:
file -
charsetName -
Returns:
arrow_up


readUtf8TextFile

public static String readUtf8TextFile(File file)


Reads a file in UTF-8 encoding.  
Parameters:
file -
Returns:
arrow_up


writeFile

public static void writeFile(File file, byte[] bytes)

Parameters:
file -
bytes -
arrow_up
Created  2004 - 10 - 21

    Poseidon for UMLTM
  UMLdoc
 PREV  CLASSIFIER    NEXT  CLASSIFIER     FRAMES    NO FRAMES      
SUMMARY:   INNER | ATTR | ASSOC | CONSTR | METHOD     DETAIL:   INNER | ATTR | ASSOC | CONSTR | METHOD     DIAGRAMS:   COLLAB | SEQ | STATE | ACTIV

Generated with Poseidon for UMLTM.
Poseidon is a registered trademark of Gentleware AG in Germany, USA and other countries. Copyright 2003-2004 Gentleware AG, Schanzenstr. 70, 20357 Hamburg, Germany. All Rights Reserved.

UML is a trademark or registered trademark of Object Management Group, Inc. in the U.S. and other countries.