net.fckeditor.tool
Class UtilsFile

java.lang.Object
  extended by net.fckeditor.tool.UtilsFile

public class UtilsFile
extends java.lang.Object

Some static helper methods in conjunction with files.

Version:
$Id: UtilsFile.java 2151 2008-07-02 22:03:15Z mosipov $

Constructor Summary
UtilsFile()
           
 
Method Summary
static void checkDirAndCreate(java.io.File dir)
          Checks for a dir and creates it if it does not exist.
static java.lang.String constructServerSidePath(javax.servlet.http.HttpServletRequest request, ResourceTypeHandler resourceType)
          Compose server-side response path.
static java.lang.String forceSingleExtension(java.lang.String filename)
          Replaces all dots except the last one with underscores in a filename.
static boolean isImage(java.io.InputStream in)
          Checks if the underlying file of the InputStream is an image.
static boolean isSingleExtension(java.lang.String filename)
          Checks if a filename contains more than one dot.
static boolean isValidPath(java.lang.String path)
          Checks if a path corresponds to the rules defined here.
static java.lang.String sanitizeFileName(java.lang.String fileName)
          Do a cleanup of the file name to avoid possible problems.
The forceSingleExtension property will be respected!
static java.lang.String sanitizeFolderName(java.lang.String folderName)
          Do a cleanup of the folder name to avoid possible problems.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtilsFile

public UtilsFile()
Method Detail

sanitizeFileName

public static java.lang.String sanitizeFileName(java.lang.String fileName)
Do a cleanup of the file name to avoid possible problems.
The forceSingleExtension property will be respected!

Parameters:
fileName -
Returns:
folder name where \ / | : ? * " < > 'control chars' replaced by '_'

sanitizeFolderName

public static java.lang.String sanitizeFolderName(java.lang.String folderName)
Do a cleanup of the folder name to avoid possible problems.

Parameters:
folderName -
Returns:
folder name where . \ / | : ? * " < > 'control chars' replaced by '_'

isImage

public static boolean isImage(java.io.InputStream in)
Checks if the underlying file of the InputStream is an image.

Parameters:
in - An input stream
Returns:
true if the underlying file is an image else false.

isValidPath

public static boolean isValidPath(java.lang.String path)
Checks if a path corresponds to the rules defined here.

Parameters:
path -
Returns:
true if path corresponds to rules or false.

forceSingleExtension

public static java.lang.String forceSingleExtension(java.lang.String filename)
Replaces all dots except the last one with underscores in a filename.

Parameters:
filename -
Returns:
string with a single dot only

isSingleExtension

public static boolean isSingleExtension(java.lang.String filename)
Checks if a filename contains more than one dot.

Parameters:
filename -
Returns:
true if filename contains severals dots else false

checkDirAndCreate

public static void checkDirAndCreate(java.io.File dir)
Checks for a dir and creates it if it does not exist.

Parameters:
dir - Directory to check/create.

constructServerSidePath

public static java.lang.String constructServerSidePath(javax.servlet.http.HttpServletRequest request,
                                                       ResourceTypeHandler resourceType)
Compose server-side response path.

Parameters:
request -
resourceType -
Returns:
server-side path of resourceType.


Copyright © 2004-2008 Frederico Caldeira Knabben. All Rights Reserved.