Package gov.nasa.arc.pds.tools.util
Class FileUtils
- java.lang.Object
-
- gov.nasa.arc.pds.tools.util.FileUtils
-
public class FileUtils extends java.lang.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 long
ONE_PB
static long
ONE_TB
static java.lang.String
OPPOSITE_SEP_CHAR
static java.lang.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(java.io.Closeable closeMe, boolean reThrowExceptions)
static boolean
containsFile(java.io.File sourceFile, java.lang.String searchName)
static void
deleteChildren(java.io.File file)
static boolean
empty(java.io.File directory)
static boolean
exists(java.io.File file)
static boolean
forceDeleteAll(java.io.File file)
static java.lang.String
fromVaxPath(java.lang.String vaxPath)
static java.io.File
getAlternateCaseFile(java.io.File rootFile, java.lang.String searchName)
static java.io.File
getBaseFile(java.io.File file)
static java.lang.String
getBaseName(java.io.File file)
static java.io.File
getCaseUnknownFile(java.io.File rootFile, java.lang.String searchName)
static java.lang.String
getContents(java.io.File file)
static java.lang.String
getExtension(java.io.File file)
static java.lang.String
getExtension(java.lang.String name)
static java.util.Map<java.lang.Integer,java.io.File>
getFileMap(java.io.File sourceFile)
static java.util.Map<java.lang.Integer,java.io.File>
getFileMap(java.io.File sourceFile, java.lang.String searchPattern)
static java.util.Map<java.lang.Integer,java.io.File>
getFileMap(java.io.File sourceFile, java.lang.String regex, boolean recursive)
static java.util.Map<java.lang.Integer,java.io.File>
getFileMap(java.util.Map<java.lang.Integer,java.io.File> sourceList, java.lang.String regex)
static java.util.Map<java.lang.Integer,java.io.File>
getFileMapByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, boolean recursive, boolean excludeSourceControlFiles)
static java.util.List<java.io.File>
getFiles(java.io.File sourceFile)
static java.util.List<java.io.File>
getFiles(java.io.File sourceFile, java.lang.String searchPattern)
static java.util.List<java.io.File>
getFiles(java.io.File sourceFile, java.lang.String regex, boolean recursive)
static java.util.List<java.io.File>
getFiles(java.util.List<java.io.File> sourceList, java.lang.String regex)
static java.util.List<java.io.File>
getFilesByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, boolean recursive)
static java.lang.String
getRegexSeparator()
static java.lang.String
getRelativePath(java.io.File baseDirectory, java.io.File targetFile)
static java.lang.String
getRelativePath(java.lang.String basePath, java.lang.String fullPath)
static java.lang.String
getRelativePath(java.net.URL baseDirectory, java.net.URL targetFile)
static java.lang.String
getSafeName(java.lang.String string)
static java.io.File
getSibling(java.lang.String fileName, java.io.File knownFile)
static java.io.File
getTopFileByPattern(java.io.File sourceFile, java.lang.String regex, java.lang.Integer maxDepth)
static java.io.File
getTopFileByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, java.lang.Integer maxDepth)
static java.io.File
getValidParent(java.io.File missingFile)
static boolean
hasParent(java.util.List<java.io.File> parents, java.io.File searchFile)
static boolean
isParent(FileMirror parent, FileMirror searchFile)
static boolean
isParent(java.io.File parent, java.io.File searchFile)
static boolean
isSourceControl(java.io.File file)
static java.util.Properties
loadProperties(java.io.File file)
static java.util.Properties
loadProperties(java.util.Properties props, java.io.File file)
-
-
-
Field Detail
-
ONE_KB
public static final long ONE_KB
The number of bytes in a kilobyte.
-
ONE_MB
public static final long ONE_MB
The number of bytes in a megabyte.
-
ONE_GB
public static final long ONE_GB
The number of bytes in a gigabyte.
-
ONE_TB
public static final long ONE_TB
-
ONE_PB
public static final long ONE_PB
-
OPPOSITE_SEP_CHAR
public static final java.lang.String OPPOSITE_SEP_CHAR
-
REGEX_SAFE_SEP
public static final java.lang.String REGEX_SAFE_SEP
-
-
Method Detail
-
containsFile
public static boolean containsFile(java.io.File sourceFile, java.lang.String searchName)
-
getFiles
public static java.util.List<java.io.File> getFiles(java.io.File sourceFile)
-
getFiles
public static java.util.List<java.io.File> getFiles(java.io.File sourceFile, java.lang.String searchPattern)
-
getFiles
public static java.util.List<java.io.File> getFiles(java.io.File sourceFile, java.lang.String regex, boolean recursive)
-
getFilesByPattern
public static java.util.List<java.io.File> getFilesByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, boolean recursive)
-
getTopFileByPattern
public static java.io.File getTopFileByPattern(java.io.File sourceFile, java.lang.String regex, java.lang.Integer maxDepth)
-
getTopFileByPattern
public static java.io.File getTopFileByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, java.lang.Integer maxDepth)
-
getFiles
public static java.util.List<java.io.File> getFiles(java.util.List<java.io.File> sourceList, java.lang.String regex)
-
getFileMap
public static java.util.Map<java.lang.Integer,java.io.File> getFileMap(java.io.File sourceFile)
-
getFileMap
public static java.util.Map<java.lang.Integer,java.io.File> getFileMap(java.io.File sourceFile, java.lang.String searchPattern)
-
getFileMap
public static java.util.Map<java.lang.Integer,java.io.File> getFileMap(java.io.File sourceFile, java.lang.String regex, boolean recursive)
-
getFileMapByPattern
public static java.util.Map<java.lang.Integer,java.io.File> getFileMapByPattern(java.io.File sourceFile, java.util.regex.Pattern searchPattern, boolean recursive, boolean excludeSourceControlFiles)
-
getFileMap
public static java.util.Map<java.lang.Integer,java.io.File> getFileMap(java.util.Map<java.lang.Integer,java.io.File> sourceList, java.lang.String regex)
-
getContents
public static java.lang.String getContents(java.io.File file) throws java.io.IOException
- Throws:
java.io.IOException
-
getBaseFile
public static java.io.File getBaseFile(java.io.File file)
-
getValidParent
public static java.io.File getValidParent(java.io.File missingFile)
-
getRelativePath
public static java.lang.String getRelativePath(java.io.File baseDirectory, java.io.File targetFile)
-
getRelativePath
public static java.lang.String getRelativePath(java.net.URL baseDirectory, java.net.URL targetFile)
-
getRelativePath
public static java.lang.String getRelativePath(java.lang.String basePath, java.lang.String fullPath)
-
getExtension
public static java.lang.String getExtension(java.lang.String name)
-
getExtension
public static java.lang.String getExtension(java.io.File file)
-
getBaseName
public static java.lang.String getBaseName(java.io.File file)
-
isParent
public static boolean isParent(java.io.File parent, java.io.File searchFile)
-
isParent
public static boolean isParent(FileMirror parent, FileMirror searchFile)
-
hasParent
public static boolean hasParent(java.util.List<java.io.File> parents, java.io.File searchFile)
-
fromVaxPath
public static java.lang.String fromVaxPath(java.lang.String vaxPath)
-
getRegexSeparator
public static java.lang.String getRegexSeparator()
-
getSibling
public static java.io.File getSibling(java.lang.String fileName, java.io.File knownFile)
-
exists
public static boolean exists(java.io.File file)
-
loadProperties
public static java.util.Properties loadProperties(java.io.File file)
-
loadProperties
public static java.util.Properties loadProperties(java.util.Properties props, java.io.File file)
-
close
public static void close(java.io.Closeable closeMe, boolean reThrowExceptions)
-
getCaseUnknownFile
public static java.io.File getCaseUnknownFile(java.io.File rootFile, java.lang.String searchName)
-
getAlternateCaseFile
public static java.io.File getAlternateCaseFile(java.io.File rootFile, java.lang.String searchName)
-
deleteChildren
public static void deleteChildren(java.io.File file)
-
forceDeleteAll
public static boolean forceDeleteAll(java.io.File file)
-
empty
public static boolean empty(java.io.File directory)
-
isSourceControl
public static boolean isSourceControl(java.io.File file)
-
getSafeName
public static java.lang.String getSafeName(java.lang.String string)
-
-