jp.sourceforge.simplefh
Interface SimpleFileAccessor

All Known Implementing Classes:
SimpleFileAccessorImpl

public interface SimpleFileAccessor

Simple file accessor interface.

It's too much of a bother to treat file resources in Java.
This module offers simple interface to treat file resources.

It is able to access os file system resource(using string file path value) or access ClassPathResource object.

Version:
1.0
Author:
Kazuhiro Sera

Method Summary
 String basename(File file)
          Get basename from path simply.
 String basename(String path)
          Get basename from path simply.
 void copy(ClassPathResource src, ClassPathResource dest)
          Copy file simply.
 void copy(File srcFile, String dest)
          Copy file simply.
 void copy(String src, String dest)
          Copy file simply.
 void delete(ClassPathResource resourcePath)
          Delete file simply.
 void delete(File targetFile)
          Delete file simply.
 void delete(String path)
          Delete file simply.
 void deleteIfExists(ClassPathResource resourcePath)
          Delete file simply if target file exists.
 void deleteIfExists(File targetFile)
          Delete file simply if target file exists.
 void deleteIfExists(String path)
          Delete file simply if target file exists.
 String dirname(File file)
          Get dirname from path simply.
 String dirname(String path)
          Get dirname from path simply.
 boolean fileExist(ClassPathResource resourcePath)
          Check file exist.
 boolean fileExist(File file)
          Check file exist.
 boolean fileExist(String path)
          Check file exist.
 void move(ClassPathResource from, ClassPathResource to)
          Move file simply.
 void move(File targetFile, String toPath)
          Move file simply.
 void move(String fromPath, String toPath)
          Move file simply.
 void rename(ClassPathResource resource, String newFilename)
          Rename file simply.
 void rename(File file, String newFilename)
          Rename file simply.
 void rename(String path, String newFilename)
          Rename file simply.
 void touch(ClassPathResource resourcePath)
          Touch file simply.
 void touch(File file)
          Touch file simply.
 void touch(String path)
          Touch file simply.
 

Method Detail

dirname

String dirname(String path)
Get dirname from path simply.

It is compatible with UNIX command.

Parameters:
path - target file path
Returns:
dirname string

dirname

String dirname(File file)
Get dirname from path simply.

It is compatible with UNIX command.

Parameters:
file - target file object
Returns:
dirname string

basename

String basename(String path)
Get basename from path simply.

It is compatible with UNIX command.

Parameters:
path - target path
Returns:
basename string

basename

String basename(File file)
Get basename from path simply.

It is compatible with UNIX command.

Parameters:
file - target file object
Returns:
basename string

copy

void copy(String src,
          String dest)
          throws IOException
Copy file simply.

Parameters:
src - src file path
dest - dest file path
Throws:
IOException - cannot copy file
ex. source file does not exist

copy

void copy(ClassPathResource src,
          ClassPathResource dest)
          throws IOException
Copy file simply.

If destination file was in archive path,
it's impossible to copy it and this method throws IOException.

Parameters:
src - ClassPathResource object
dest - ClassPathResource object
Throws:
IOException - cannot access resources

copy

void copy(File srcFile,
          String dest)
          throws IOException
Copy file simply.

Parameters:
srcFile - src file
dest - dest file path
Throws:
IOException - cannot copy file
ex. source file does not exist

delete

void delete(String path)
            throws IOException
Delete file simply.

Parameters:
path - target file path
Throws:
IOException - cannot delete file
ex. file does not exist, locked

delete

void delete(ClassPathResource resourcePath)
            throws IOException
Delete file simply.

If target file was in archive path,
it's impossible to delete it and this method throws IOException.

Parameters:
resourcePath - ClassPathResource object
Throws:
IOException - cannot access resources

delete

void delete(File targetFile)
            throws IOException
Delete file simply.

Parameters:
targetFile - target file object
Throws:
IOException - cannot delete file
ex. file does not exist, locked

deleteIfExists

void deleteIfExists(String path)
                    throws IOException
Delete file simply if target file exists.

Parameters:
path - target file path
Throws:
IOException - cannot delete file
ex. file does not exist, locked

deleteIfExists

void deleteIfExists(ClassPathResource resourcePath)
                    throws IOException
Delete file simply if target file exists.

If target file was in archive path,
it's impossible to delete it and this method throws IOException.

Parameters:
resourcePath - ClassPathResource object
Throws:
IOException - cannot access resources

deleteIfExists

void deleteIfExists(File targetFile)
                    throws IOException
Delete file simply if target file exists.

Parameters:
targetFile - target file object
Throws:
IOException - cannot delete file
ex. file does not exist, locked

move

void move(String fromPath,
          String toPath)
          throws IOException
Move file simply.

Parameters:
fromPath - from file path
toPath - to file path
Throws:
IOException - cannot move file
ex. from file not found, locked

move

void move(ClassPathResource from,
          ClassPathResource to)
          throws IOException
Move file simply.

If target file or destination file was in archive path,
it's impossible to move it and this method throws IOException.

Parameters:
from - ClassPathResource from resource
to - ClassPathResource to resource
Throws:
IOException - cannot access resources

move

void move(File targetFile,
          String toPath)
          throws IOException
Move file simply.

Parameters:
targetFile - from file object
toPath - to file path
Throws:
IOException - cannot move file
ex. from file not found, locked

rename

void rename(String path,
            String newFilename)
            throws IOException
Rename file simply.

Parameters:
path - target file path
newFilename - new file name
Throws:
IOException - cannot rename file
ex. from file not found, locked

rename

void rename(ClassPathResource resource,
            String newFilename)
            throws IOException
Rename file simply.

If target file or destination file was in archive path,
it's impossible to rename it and this method throws IOException.

Parameters:
resource - ClassPathResource resource
newFilename - new file name
Throws:
IOException - cannot access resources

rename

void rename(File file,
            String newFilename)
            throws IOException
Rename file simply.

Parameters:
file - target file object
newFilename - new file name
Throws:
IOException - cannot rename file
ex. from file not found, locked

touch

void touch(String path)
           throws IOException
Touch file simply.

Parameters:
path - target file path
Throws:
IOException - cannot touch file

touch

void touch(ClassPathResource resourcePath)
           throws IOException
Touch file simply.

If target file was in archive path,
it's impossible to touch it and this method throws IOException.

Parameters:
resourcePath - ClassPathResource resource
Throws:
IOException - cannot access resources

touch

void touch(File file)
           throws IOException
Touch file simply.

Parameters:
file - target file object
Throws:
IOException - cannot touch file

fileExist

boolean fileExist(String path)
Check file exist.

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

fileExist

boolean fileExist(ClassPathResource resourcePath)
Check file exist.

Parameters:
resourcePath - ClassPathResource resource
Returns:
result boolean value

fileExist

boolean fileExist(File file)
Check file exist.

Parameters:
file - target file object
Returns:
result boolean value