net.sf.hermesftp.utils
Class IOUtils

java.lang.Object
  extended by net.sf.hermesftp.utils.IOUtils

public final class IOUtils
extends java.lang.Object

This class contains some functionallity concerning I/O communication not covered by IOUtils.

Author:
Lars Behnke

Method Summary
static boolean closeGracefully(java.lang.Object o)
          Closes a file, socket, stream, writer etc. without throwing exceptions.
static java.lang.String formatUnixFtpFileInfo(java.io.File file, boolean read, boolean write)
          Returns a line formated directory entry.
static java.util.Properties getAppProperties()
          Returns application properties (app.properties).
static java.io.File getHomeDir()
          Tries to figure out the application's home directory.
static boolean isUNCSupported()
          Checks, if UNC file naming is supported.
static java.lang.String loadTextResource(java.lang.String name, java.lang.String encoding)
          Reads an arbitrary text resource from the class path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

closeGracefully

public static boolean closeGracefully(java.lang.Object o)
Closes a file, socket, stream, writer etc. without throwing exceptions. Any exception is catched and logged. In contrast to the "Commons IO" method closeQuietly() this method closes any object that has a close()-method and is not restricted to readers, writers and streams.

Parameters:
o - The object to be closed.
Returns:
True, if object could be closed.

formatUnixFtpFileInfo

public static java.lang.String formatUnixFtpFileInfo(java.io.File file,
                                                     boolean read,
                                                     boolean write)
Returns a line formated directory entry. The permissions are set as follows: The passed read flag is relevant for owner, group and others. The passed write flag is only relevant for the owner.

Parameters:
file - The file to be formatted.
read - True if readable.
write - True if writable.
Returns:
The formatted line.

loadTextResource

public static java.lang.String loadTextResource(java.lang.String name,
                                                java.lang.String encoding)
                                         throws java.io.IOException
Reads an arbitrary text resource from the class path.

Parameters:
name - The name of the resource.
encoding - The text encoding.
Returns:
The text.
Throws:
java.io.IOException - Error on accessing the resource.

getAppProperties

public static java.util.Properties getAppProperties()
Returns application properties (app.properties).

Returns:
The properties object.

getHomeDir

public static java.io.File getHomeDir()
Tries to figure out the application's home directory.

Returns:
The directory.

isUNCSupported

public static boolean isUNCSupported()
Checks, if UNC file naming is supported.

Returns:
True, if UNC supported.


Copyright © 2005-2007 Lars Behnke. All Rights Reserved.