net.sourceforge.sconman.helpers
Class FileHelper

java.lang.Object
  extended by net.sourceforge.sconman.helpers.FileHelper

public class FileHelper
extends java.lang.Object

Helper methods for contents in files and directories.

Author:
mikeshadow

Nested Class Summary
static interface FileHelper.IFileVisitor
          Interface for visitor pattern
 
Constructor Summary
FileHelper()
           
 
Method Summary
static void delete(java.io.File f)
          Deletes a directory and subdirectories
static java.lang.String getDirPath(java.lang.String path)
          Returns the content's dir path, relative to the filestore
static java.lang.String getExtension(java.lang.String fileName)
          Returns the file's extension (substring from last '.')
static java.lang.String getFileName(java.lang.String path)
          Returns the file id
static java.lang.String getFileNameWithoutExt(java.lang.String filePath)
           
static java.lang.String getRelativePath(java.lang.String root, java.lang.String path)
          Returns the relative path from root to path.
static void visitFiles(java.io.File file, FileHelper.IFileVisitor fv)
          Visitor pattern implementation for File objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHelper

public FileHelper()
Method Detail

visitFiles

public static void visitFiles(java.io.File file,
                              FileHelper.IFileVisitor fv)
Visitor pattern implementation for File objects. This methods explores recursively a directory tree from the given point and invokes the visitor method for each found file.

Parameters:
file - The starting point for the visit
fv - The Visitor who wants to explore the file tree

delete

public static void delete(java.io.File f)
Deletes a directory and subdirectories

Parameters:
f -

getExtension

public static java.lang.String getExtension(java.lang.String fileName)
Returns the file's extension (substring from last '.')

Parameters:
fileName - The file
Returns:
The file's extension

getFileName

public static java.lang.String getFileName(java.lang.String path)
Returns the file id

Parameters:
path - The file path
Returns:
The file id

getDirPath

public static java.lang.String getDirPath(java.lang.String path)
Returns the content's dir path, relative to the filestore

Parameters:
content -
Returns:

getFileNameWithoutExt

public static java.lang.String getFileNameWithoutExt(java.lang.String filePath)
Parameters:
filePath -
Returns:

getRelativePath

public static java.lang.String getRelativePath(java.lang.String root,
                                               java.lang.String path)
                                        throws java.io.IOException
Returns the relative path from root to path. NOTE: it spects that path is under root, so other cases are not considered yet

Parameters:
root -
path -
Returns:
Throws:
java.io.IOException


Copyright null null. All Rights Reserved.