Package gov.nasa.arc.pds.tools.util
Class FileUtils
- java.lang.Object
-
- gov.nasa.arc.pds.tools.util.FileUtils
-
public class FileUtils extends Object
A helper class for File related functionality.- Version:
- $Revision: $
- Author:
- jagander
-
-
Field Summary
Fields Modifier and Type Field Description static long
ONE_GB
The number of bytes in a gigabyte.static long
ONE_KB
The number of bytes in a kilobyte.static long
ONE_MB
The number of bytes in a megabyte.static String
OPPOSITE_SEP_CHAR
static String
REGEX_SAFE_SEP
-
Constructor Summary
Constructors Constructor Description FileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(Closeable closeMe, boolean reThrowExceptions)
static boolean
containsFile(File sourceFile, String searchName)
static void
deleteChildren(File file)
static boolean
empty(File directory)
static boolean
exists(File file)
static boolean
forceDeleteAll(File file)
static String
fromVaxPath(String vaxPath)
static File
getAlternateCaseFile(File rootFile, String searchName)
static File
getBaseFile(File file)
static String
getBaseName(File file)
static File
getCaseUnknownFile(File rootFile, String searchName)
static String
getContents(File file)
static String
getExtension(File file)
static String
getExtension(String name)
static Map<Integer,File>
getFileMap(File sourceFile)
static Map<Integer,File>
getFileMap(File sourceFile, String searchPattern)
static Map<Integer,File>
getFileMap(File sourceFile, String regex, boolean recursive)
static Map<Integer,File>
getFileMap(Map<Integer,File> sourceList, String regex)
static Map<Integer,File>
getFileMapByPattern(File sourceFile, Pattern searchPattern, boolean recursive, boolean excludeSourceControlFiles)
static List<File>
getFiles(File sourceFile)
static List<File>
getFiles(File sourceFile, String searchPattern)
static List<File>
getFiles(File sourceFile, String regex, boolean recursive)
static List<File>
getFiles(List<File> sourceList, String regex)
static List<File>
getFilesByPattern(File sourceFile, Pattern searchPattern, boolean recursive)
static String
getRegexSeparator()
static String
getRelativePath(File baseDirectory, File targetFile)
static String
getRelativePath(String basePath, String fullPath)
static String
getRelativePath(URL baseDirectory, URL targetFile)
static String
getSafeName(String string)
static File
getSibling(String fileName, File knownFile)
static File
getTopFileByPattern(File sourceFile, String regex, Integer maxDepth)
static File
getTopFileByPattern(File sourceFile, Pattern searchPattern, Integer maxDepth)
static File
getValidParent(File missingFile)
static boolean
hasParent(List<File> parents, File searchFile)
static boolean
isParent(FileMirror parent, FileMirror searchFile)
static boolean
isParent(File parent, File searchFile)
static boolean
isSourceControl(File file)
static Properties
loadProperties(File file)
static Properties
loadProperties(Properties props, File file)
-
-
-
Field Detail
-
ONE_KB
public static final long ONE_KB
The number of bytes in a kilobyte.- See Also:
- Constant Field Values
-
ONE_MB
public static final long ONE_MB
The number of bytes in a megabyte.- See Also:
- Constant Field Values
-
ONE_GB
public static final long ONE_GB
The number of bytes in a gigabyte.- See Also:
- Constant Field Values
-
OPPOSITE_SEP_CHAR
public static final String OPPOSITE_SEP_CHAR
-
REGEX_SAFE_SEP
public static final String REGEX_SAFE_SEP
-
-
Method Detail
-
getFilesByPattern
public static List<File> getFilesByPattern(File sourceFile, Pattern searchPattern, boolean recursive)
-
getTopFileByPattern
public static File getTopFileByPattern(File sourceFile, String regex, Integer maxDepth)
-
getTopFileByPattern
public static File getTopFileByPattern(File sourceFile, Pattern searchPattern, Integer maxDepth)
-
getFileMap
public static Map<Integer,File> getFileMap(File sourceFile, String regex, boolean recursive)
-
getFileMapByPattern
public static Map<Integer,File> getFileMapByPattern(File sourceFile, Pattern searchPattern, boolean recursive, boolean excludeSourceControlFiles)
-
getFileMap
public static Map<Integer,File> getFileMap(Map<Integer,File> sourceList, String regex)
-
getContents
public static String getContents(File file) throws IOException
- Throws:
IOException
-
isParent
public static boolean isParent(FileMirror parent, FileMirror searchFile)
-
getRegexSeparator
public static String getRegexSeparator()
-
exists
public static boolean exists(File file)
-
loadProperties
public static Properties loadProperties(File file)
-
loadProperties
public static Properties loadProperties(Properties props, File file)
-
close
public static void close(Closeable closeMe, boolean reThrowExceptions)
-
deleteChildren
public static void deleteChildren(File file)
-
forceDeleteAll
public static boolean forceDeleteAll(File file)
-
empty
public static boolean empty(File directory)
-
isSourceControl
public static boolean isSourceControl(File file)
-
-