jp.sourceforge.simplefh.util
Class FileResourceUtil

java.lang.Object
  extended by jp.sourceforge.simplefh.util.FileResourceUtil

public class FileResourceUtil
extends Object

Utility for file resource.

Version:
1.0
Author:
Kazuhiro Sera

Constructor Summary
FileResourceUtil()
           
 
Method Summary
static void close(BufferedInputStream bis)
          Close resource safely.
static void close(BufferedReader br)
          Close resource safely.
static void close(FileOutputStream fos)
          Close resource safely.
static void close(InputStream is)
          Close resource safely.
static void close(InputStreamReader isr)
          Close resource safely.
static String getDetectedEncoding(InputStream is)
          Get detected encoding.
static String getFileSystemAbsolutePath(String resourcePathOrFilePath)
          Get file system absolute path.
static InputStream getInputStreamFromResourceOrFileSystem(String resourcePathOrFilePath)
          Get InputStream from resource path or file system full path.
static String getResourceRootPath(String resourcePath, String absolutePath)
          Get Resource root path.
static boolean isFileAccessAvailable(String absolutePath)
          Judge target absolute path is available to access on os file system.
static String replaceAllBackSlash2Slash(String absolutePath)
          Replace all back slash to slash.
(for convert Windows platform directory separator)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileResourceUtil

public FileResourceUtil()
Method Detail

isFileAccessAvailable

public static boolean isFileAccessAvailable(String absolutePath)
Judge target absolute path is available to access on os file system.

Parameters:
absolutePath - target file absolute path
Returns:
result boolean value

getDetectedEncoding

public static String getDetectedEncoding(InputStream is)
                                  throws IOException
Get detected encoding.

Parameters:
is -
Returns:
Throws:
IOException

replaceAllBackSlash2Slash

public static String replaceAllBackSlash2Slash(String absolutePath)
Replace all back slash to slash.
(for convert Windows platform directory separator)

Parameters:
target - target absolute file path
Returns:
result

getFileSystemAbsolutePath

public static String getFileSystemAbsolutePath(String resourcePathOrFilePath)
Get file system absolute path.

Parameters:
resourcePathOrFilePath - target path(fs path or resource path)
Returns:
fs absolute path

getResourceRootPath

public static String getResourceRootPath(String resourcePath,
                                         String absolutePath)
Get Resource root path.

Parameters:
resourcePath - resource path
absolutePath - file system absolute path
Returns:
resource root path

getInputStreamFromResourceOrFileSystem

public static InputStream getInputStreamFromResourceOrFileSystem(String resourcePathOrFilePath)
                                                          throws FileNotFoundException
Get InputStream from resource path or file system full path.

Parameters:
resourcePathOrFilePath -
Returns:
Input Stream
Throws:
FileNotFoundException

close

public static void close(InputStream is)
Close resource safely.

Parameters:
is - InputStream resource object

close

public static void close(InputStreamReader isr)
Close resource safely.

Parameters:
isr - InputStreamReader resource object

close

public static void close(BufferedReader br)
Close resource safely.

Parameters:
br - BufferedReader resource object

close

public static void close(BufferedInputStream bis)
Close resource safely.

Parameters:
bis - BufferedInputStream resource object

close

public static void close(FileOutputStream fos)
Close resource safely.

Parameters:
bis - FileOutputStream resource object