public class FileUtils
extends java.lang.Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
basename(java.lang.String filename)
Returns the filename portion of a specific file string.
|
static java.lang.String |
basename(java.lang.String filename,
java.lang.String suffix)
Returns the filename portion of a specific file string.
|
static void |
copyDirectory(java.io.File sourceDirectory,
java.io.File destDirectory)
Copy file from source directory to destination directory.
|
static void |
copyDirectory(java.lang.String sourceDirectory,
java.lang.String destDirectory)
Copy file from source directory to destination directory.
|
static void |
copyFile(java.io.File sourceFile,
java.io.File destFile)
Copy file from source to destination.
|
static void |
copyFile(java.lang.String sourceFile,
java.lang.String destFile)
Copy file from source to destination.
|
static void |
copyFileToDirectory(java.io.File sourceFile,
java.io.File destDirectory)
Copy file from source to destination.
|
static void |
copyFileToDirectory(java.lang.String sourceFile,
java.lang.String destDirectory)
Copy file from source to destination.
|
static java.lang.String |
dirname(java.lang.String filename)
Returns the directory path portion of a specific file string.
|
static java.lang.String |
extension(java.lang.String filename)
Returns the extension portion of a specific file string.
|
static java.lang.String |
filename(java.lang.String filename)
Returns the filename portion of a specific file string.
|
static java.util.Set |
getAllFiles(java.io.File dir)
Given a directory, return the set of files in that directory.
|
static java.lang.String |
getExtension(java.lang.String filename)
Get extension from filename.
|
static java.lang.String |
getPath(java.lang.String filepath)
Get path from filename.
|
static java.lang.String |
getPath(java.lang.String filepath,
char fileSeparatorChar)
Get path from filename.
|
static java.io.File |
getRelativeFile(java.io.File dir,
java.io.File file)
Returns a file whose path is the relative path to that
of the given directory.
|
static java.util.Set |
getRelativeFiles(java.util.Set files,
java.io.File dir) |
static boolean |
isValidDirectory(java.lang.String dirName)
Validates directory name.
|
static boolean |
isValidFileAndPath(java.lang.String fileNameAndPath)
Validates filename with wildcard and path
|
static boolean |
isValidFileName(java.lang.String fileName)
Validates file name.
|
static java.lang.String |
removeExtension(java.lang.String filename)
Remove extension from filename.
|
static java.lang.String |
removePath(java.lang.String filepath)
Remove path from filename.
|
static java.lang.String |
removePath(java.lang.String filepath,
char fileSeparatorChar)
Remove path from filename.
|
static boolean |
unZipFiles(java.lang.String fileName,
java.lang.String destFolder,
java.lang.String osaHome)
Extracts contents a compressed file into the specified folder.
|
static void |
uploadFile(byte[] data,
java.lang.String uploadLocation,
java.lang.String fileName)
Uploads the file with given file name to the given upload location.
|
static boolean |
zipFiles(java.lang.String[] fileNames,
java.lang.String zipFile,
java.lang.String destFolder,
boolean storePath,
java.lang.String osaHome)
Creates compressed archive of files passed to it
and stores the archive into the specified folder.
|
public static java.io.File getRelativeFile(java.io.File dir, java.io.File file) throws java.io.FileNotFoundException
java.io.FileNotFoundException
public static java.util.Set getAllFiles(java.io.File dir)
public static java.util.Set getRelativeFiles(java.util.Set files, java.io.File dir)
public static java.lang.String dirname(java.lang.String filename)
filename
- public static java.lang.String filename(java.lang.String filename)
filename
- public static java.lang.String basename(java.lang.String filename)
filename
- public static java.lang.String basename(java.lang.String filename, java.lang.String suffix)
filename
- suffix
- public static java.lang.String extension(java.lang.String filename)
filename
- public static java.lang.String removeExtension(java.lang.String filename)
filename
- the filenamepublic static java.lang.String getExtension(java.lang.String filename)
filename
- the filenamepublic static java.lang.String removePath(java.lang.String filepath)
filepath
- the filepathpublic static java.lang.String removePath(java.lang.String filepath, char fileSeparatorChar)
filepath
- - the file pathpublic static java.lang.String getPath(java.lang.String filepath)
filepath
- the filepathpublic static java.lang.String getPath(java.lang.String filepath, char fileSeparatorChar)
filepath
- the filepathpublic static void copyFileToDirectory(java.lang.String sourceFile, java.lang.String destDirectory) throws java.lang.Exception
sourceFile
- - the source file to been copy.destDirectory
- - the destination directory to copy to.java.lang.Exception
public static void copyFileToDirectory(java.io.File sourceFile, java.io.File destDirectory) throws java.lang.Exception
sourceFile
- - the source file to been copy.destDirectory
- - the destination directory to copy to.java.lang.Exception
public static void copyDirectory(java.io.File sourceDirectory, java.io.File destDirectory) throws java.lang.Exception
sourceDirectory
- - source directory to copy from.destDirectory
- - destination directory to copy to.java.lang.Exception
public static void copyDirectory(java.lang.String sourceDirectory, java.lang.String destDirectory) throws java.lang.Exception
sourceDirectory
- - source directory to copy from.destDirectory
- - destination directory to copy to.java.lang.Exception
public static void copyFile(java.io.File sourceFile, java.io.File destFile) throws java.lang.Exception
sourceFile
- - the source file to copy.destFile
- - the destination file to copy to.java.lang.Exception
public static void copyFile(java.lang.String sourceFile, java.lang.String destFile) throws java.lang.Exception
sourceFile
- - the source file to copy.destFile
- - the destination file to copy to.java.lang.Exception
public static boolean isValidFileName(java.lang.String fileName)
fileName
- - the file name to be validatedpublic static boolean isValidDirectory(java.lang.String dirName)
dirName
- - the directory name to be validatedpublic static boolean isValidFileAndPath(java.lang.String fileNameAndPath)
fileNameAndPath
- - the filename with wildcard and path to be validatedpublic static boolean zipFiles(java.lang.String[] fileNames, java.lang.String zipFile, java.lang.String destFolder, boolean storePath, java.lang.String osaHome)
fileNames
- array of filenames or folder names which need to compressed.zipFile
- the name of file in which the compressed archive will be stored.destFolder
- the folder name where the compressed archive will be stored.storePath
- true if file path should be stored in the archive otherwise false.osaHome
- the path where Network Mediation is installed.public static boolean unZipFiles(java.lang.String fileName, java.lang.String destFolder, java.lang.String osaHome)
fileName
- the compressed filedestFolder
- the folder where the compressed file should be extracted.public static void uploadFile(byte[] data, java.lang.String uploadLocation, java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
data
- File's datauploadLocation
- Location where file needs to be uploadedfileName
- File's namejava.io.FileNotFoundException
- Exception thrown when file is not foundjava.io.IOException
- Exception thrown while writing to the file