public class FileTools extends Object
FileTools class.
Modifier and Type | Class and Description |
---|---|
static class |
FileTools.LocalhostPair |
Modifier and Type | Field and Description |
---|---|
static String |
FORCE_HOST |
Constructor and Description |
---|
FileTools() |
Modifier and Type | Method and Description |
---|---|
static String |
byte2HexString(byte[] b)
byte2HexString.
|
static File |
createDirectoryWithUniqueName(File parentDir,
String prefix)
createDirectoryWithUniqueName.
|
static File |
createFileWithUniqueName(File parentDir,
String prefix)
createFileWithUniqueName.
|
static File |
createTempDirectory(File parentDir)
createTempDirectory.
|
static boolean |
deleteDirectoryRecursive(File path)
deleteDirectoryRecursive.
|
static ReturnValue |
dirPathExistsAndReadable(File file)
dirPathExistsAndReadable.
|
static ReturnValue |
dirPathExistsAndWritable(File file)
dirPathExistsAndWritable.
|
static ReturnValue |
fileExistsAndNotEmpty(File file)
fileExistsAndNotEmpty.
|
static ReturnValue |
fileExistsAndReadable(File file)
fileExistsAndReadable.
|
static String |
getFilename(String filePath) |
static String |
getFilePath(String filePath) |
static Map<String,String> |
getKeyValueFromFile(String path)
getKeyValueFromFile.
|
static FileTools.LocalhostPair |
getLocalhost(joptsimple.OptionSet options)
Get the localhost and a return value describing the failure condition if we are unable to get the localhost
|
static boolean |
isFileOwner(String path)
This tool uses the 'whoami' and 'stat' commands to verify if the current users running this program is the owner for the specified
file or directory.
|
static void |
listFilesRecursive(File path,
ArrayList<File> filesArray)
listFilesRecursive.
|
static boolean |
unzipFile(File path,
File outputDir)
FIXME: should make this optional to keep the original file
|
static ReturnValue |
verifyFile(File file)
verifyFile.
|
static String |
whoAmI()
This tool uses the 'whoami' command to find the current user versus the user.name method.
|
static boolean |
zipDirectoryRecursive(File path,
File zipFileName,
String excludeRegEx,
boolean relative,
boolean compress)
zipDirectoryRecursive.
|
static boolean |
zipListFileRecursiveOld(List<File> filesToZip,
File zipFileName,
String cutPrefix,
String excludeRegEx,
boolean compress)
zipListFileRecursiveOld.
|
public static final String FORCE_HOST
public static String byte2HexString(byte[] b)
byte2HexString.
b
- an array of byte.String
object.public static ReturnValue verifyFile(File file)
verifyFile.
file
- a File
object.ReturnValue
object.public static ReturnValue dirPathExistsAndWritable(File file)
dirPathExistsAndWritable.
file
- a File
object.ReturnValue
object.public static ReturnValue dirPathExistsAndReadable(File file)
dirPathExistsAndReadable.
file
- a File
object.ReturnValue
object.public static ReturnValue fileExistsAndReadable(File file)
fileExistsAndReadable.
file
- a File
object.ReturnValue
object.public static ReturnValue fileExistsAndNotEmpty(File file)
fileExistsAndNotEmpty.
file
- a File
object.ReturnValue
object.public static File createTempDirectory(File parentDir) throws IOException
createTempDirectory.
parentDir
- a File
object.File
object.IOException
- if any.public static File createDirectoryWithUniqueName(File parentDir, String prefix) throws IOException
createDirectoryWithUniqueName.
parentDir
- a File
object.prefix
- a String
object.File
object.IOException
- if any.public static File createFileWithUniqueName(File parentDir, String prefix) throws IOException
createFileWithUniqueName.
parentDir
- a File
object.prefix
- a String
object.File
object.IOException
- if any.public static boolean deleteDirectoryRecursive(File path)
deleteDirectoryRecursive.
path
- a File
object.public static boolean zipDirectoryRecursive(File path, File zipFileName, String excludeRegEx, boolean relative, boolean compress)
zipDirectoryRecursive.
public static boolean zipListFileRecursiveOld(List<File> filesToZip, File zipFileName, String cutPrefix, String excludeRegEx, boolean compress)
zipListFileRecursiveOld.
public static boolean unzipFile(File path, File outputDir)
public static void listFilesRecursive(File path, ArrayList<File> filesArray)
listFilesRecursive.
public static Map<String,String> getKeyValueFromFile(String path)
getKeyValueFromFile.
public static boolean isFileOwner(String path)
path
- public static String whoAmI()
public static FileTools.LocalhostPair getLocalhost(joptsimple.OptionSet options)
options
- (looks for force-host as an override, will ignore if null)Copyright © 2015 SeqWare. All rights reserved.