org.ow2.jonas.launcher.jonas.util
Class IOUtils

java.lang.Object
  extended by org.ow2.jonas.launcher.jonas.util.IOUtils

public final class IOUtils
extends java.lang.Object

IO utilities.

Author:
Guillaume Sauthier

Method Summary
static boolean deleteDir(java.io.File dir)
          Recursively delete a directory.
static boolean exists(java.lang.String filename)
          Checks if the file exists.
static java.util.Properties getPropertiesFromClass(java.lang.String resource, java.lang.Class<?> clazz)
           
static java.util.Properties getPropertiesFromFile(java.io.File filename)
           
static java.io.File getSystemFile(java.io.File base, java.lang.String relative)
          Return a OS valid File.
static java.lang.String getSystemPath(java.io.File base, java.lang.String relative)
          Return a OS valid path.
static java.util.Properties loadPropertiesFromStream(java.io.InputStream is)
          Create a Properties from the given InputStream.
static java.util.Map<java.lang.String,java.lang.String> props2Map(java.util.Properties p)
          Convert the given properties object into a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deleteDir

public static boolean deleteDir(java.io.File dir)
Recursively delete a directory.

Parameters:
dir - directory to be deleted
Returns:
true if everything went smoothly.

getSystemPath

public static java.lang.String getSystemPath(java.io.File base,
                                             java.lang.String relative)
Return a OS valid path.

Parameters:
base - basis directory
relative - relative path name to the basis directory
Returns:
the OS dependent path name

getSystemFile

public static java.io.File getSystemFile(java.io.File base,
                                         java.lang.String relative)
Return a OS valid File.

Parameters:
base - basis directory
relative - relative path name to the basis directory
Returns:
the OS dependent File

exists

public static boolean exists(java.lang.String filename)
Checks if the file exists.

Parameters:
filename - File name to be tested
Returns:
true if the given file exists.

getPropertiesFromFile

public static java.util.Properties getPropertiesFromFile(java.io.File filename)
                                                  throws java.io.IOException
Parameters:
filename - properties file name
Returns:
the content of the resource as a Properties instance.
Throws:
java.io.IOException - if file is not found or if file is not a property file.

loadPropertiesFromStream

public static java.util.Properties loadPropertiesFromStream(java.io.InputStream is)
                                                     throws java.io.IOException
Create a Properties from the given InputStream. Close the stream at the end of the operation.

Parameters:
is - InputStream
Returns:
properties
Throws:
java.io.IOException - if the stream cannot be read or if it doesn't contains a Properties

props2Map

public static java.util.Map<java.lang.String,java.lang.String> props2Map(java.util.Properties p)
Convert the given properties object into a map.

Parameters:
p - the properties object
Returns:
a map

getPropertiesFromClass

public static java.util.Properties getPropertiesFromClass(java.lang.String resource,
                                                          java.lang.Class<?> clazz)
                                                   throws java.io.IOException
Parameters:
resource - properties file name (relative to org/ow2/jonas/launcher/jonas)
Returns:
the content of the resource as a Properties instance.
Throws:
java.io.IOException - if file is not found or if file is not a property file.


Copyright © 2012 OW2 Consortium. All Rights Reserved.