net.sourceforge.atunes.kernel.utils
Class FileNameUtils

java.lang.Object
  extended by net.sourceforge.atunes.kernel.utils.FileNameUtils

public class FileNameUtils
extends java.lang.Object

Utility methods for replacing illegal characters in filenames

The getValidFileName method is designed to handle filenames only, so do not pass the whole path. For folders, use the getValidFolderName function, but do not pass the filename with the folder name. Folder name can include full path, except as said the filename. We are as permissive as possible, which means this can cause interoperability problems (songs ripped on a Unix-like system then played on a Windows OS for example). Further, we do not check what file system is used, which can cause problems when writing to a FAT/FAT32 partition for example. We do not yet check the filename length (255 characters max for all OS).

The characters in the list are probably incomplete and users might want other substitutions so please change and complete accordingly.


Constructor Summary
FileNameUtils()
           
 
Method Summary
static java.lang.String getValidFileName(java.lang.String fileName)
          Checks for valid filenames.
static java.lang.String getValidFileName(java.lang.String fileNameStr, boolean isMp3Device)
          Checks for valid filenames.
static java.lang.String getValidFolderName(java.lang.String folderName)
          Checks for valid folder names.
static java.lang.String getValidFolderName(java.lang.String folderNameStr, boolean isMp3Device)
          Checks for valid folder names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileNameUtils

public FileNameUtils()
Method Detail

getValidFileName

public static java.lang.String getValidFileName(java.lang.String fileName)
Checks for valid filenames. Only pass the filename without path! The filename is not checked for maximum filename length of 255 characters (including path!). To check for valid folder names please use getValidFolderName(String folderName)

Parameters:
fileName - The filename to be checked. Please make sure to check for escape sequences (\, $) and add a \ before them before calling this method.
Returns:
Returns the filename with known illegal characters substituted.

getValidFileName

public static java.lang.String getValidFileName(java.lang.String fileNameStr,
                                                boolean isMp3Device)
Checks for valid filenames. Only pass the filename without path! The filename is not checked for maximum filename lenght of 255 characters (including path!). To check for valid folder names please use getValidFolderName(String folderName)

Parameters:
fileNameStr - The filename to be checked. Please make sure to check for escape sequences (\, $) and add a \ before them before calling this method.
isMp3Device - if valid file name for Mp3 device (->FAT/FAT32)
Returns:
Returns the filename with known illegal characters substituted.

getValidFolderName

public static java.lang.String getValidFolderName(java.lang.String folderName)
Checks for valid folder names. Do pass the path WITHOUT the filename. The folder name is not checked for maximum length of 255 characters (including filename!). To check for valid filenames please use getValidFileName(String fileName)

Parameters:
folderName - The folder name to be checked.
Returns:
Returns the path name with known illegal characters substituted.

getValidFolderName

public static java.lang.String getValidFolderName(java.lang.String folderNameStr,
                                                  boolean isMp3Device)
Checks for valid folder names. Do pass the path WITHOUT the filename. The folder name is not checked for maximum length of 255 characters (including filename!). To check for valid filenames please use getValidFileName(String fileName)

Parameters:
folderNameStr - The folder name to be checked.
isMp3Device - if valid folder name for Mp3 device (->FAT/FAT32)
Returns:
Returns the path name with known illegal characters substituted.


Copyright © 2006-2008 The aTunes Team. All Rights Reserved.