Class Information
Package: com.onepg.util
Class Name: FileUtil
Description
Method List
getOsTemporaryPath
public String getOsTemporaryPath()
- Specifically, returns the path of the Java java.io.tmpdir system property.
Return Value
String - the OS temporary directory path
joinPath
public String joinPath(String... paths)
- Passing blank at the end of arguments returns a path ending with / or \.
- The separator is the OS-appropriate character.
Parameters
| Name | Type | Description |
|---|---|---|
paths |
String... |
file paths (multiple specification) |
Return Value
String - the file path
convOsPath
public String convOsPath(String path)
- The separator is replaced with the OS-appropriate character.
Parameters
| Name | Type | Description |
|---|---|---|
path |
String |
file path |
Return Value
String - the file path
convAbsolutePath
public String convAbsolutePath(String path)
- Relative paths are converted to absolute paths.
- The separator is replaced with the OS-appropriate character.
Parameters
| Name | Type | Description |
|---|---|---|
path |
String |
relative path |
Return Value
String - the absolute path
exists
public boolean exists(String checkPath)
Parameters
| Name | Type | Description |
|---|---|---|
checkPath |
String |
path to check |
Return Value
boolean - true if exists
existsParent
public boolean existsParent(String checkPath)
Parameters
| Name | Type | Description |
|---|---|---|
checkPath |
String |
path to check |
Return Value
boolean - true if exists
getFileName
public String getFileName(String fullPath)
Parameters
| Name | Type | Description |
|---|---|---|
fullPath |
String |
full path |
Return Value
String - the file name only
getParentPath
public String getParentPath(String fullPath)
Parameters
| Name | Type | Description |
|---|---|---|
fullPath |
String |
full path |
Return Value
String - the parent directory path
getFileModifiedDateTime
public String getFileModifiedDateTime(String fullPath)
Parameters
| Name | Type | Description |
|---|---|---|
fullPath |
String |
full path |
Return Value
String - the file modified date-time (yyyyMMddHHmmss)
splitFileTypeMark
public String[] splitFileTypeMark(String fileName)
Parameters
| Name | Type | Description |
|---|---|---|
fileName |
String |
file name or full path |
Return Value
String[] - the string array {part before extension, extension} (neither includes the dot)
getFileList
public List<String> getFileList(String dirPath, String typeMark, String prefixMatch, String middleMatch, String suffixMatch)
- File name and extension search strings are case-insensitive.
Parameters
| Name | Type | Description |
|---|---|---|
dirPath |
String |
target directory path |
typeMark |
String |
search extension (optional) null if omitted ※ dot character not required |
prefixMatch |
String |
search file name prefix match (optional) null if omitted |
middleMatch |
String |
search file name middle match (optional) null if omitted |
suffixMatch |
String |
search file name suffix match (optional) null if omitted |
Return Value
List<String> - the file path (absolute path) list
move
public File move(String srcFilePath, String destFilePath)
Parameters
| Name | Type | Description |
|---|---|---|
srcFilePath |
String |
source file path |
destFilePath |
String |
destination file path (directory specification allowed) |
Return Value
File - the destination file object
See Also
move
public File move(File srcFile, File destFile)
- If the destination is a directory specification, the file name will be the same as the source.
Parameters
| Name | Type | Description |
|---|---|---|
srcFile |
File |
source file |
destFile |
File |
destination file (directory specification allowed) |
Return Value
File - the destination file object
copy
public File copy(String srcFilePath, String destFilePath)
Parameters
| Name | Type | Description |
|---|---|---|
srcFilePath |
String |
source file path |
destFilePath |
String |
destination file path (directory specification allowed) |
Return Value
File - the destination file object
See Also
copy
public File copy(File srcFile, File destFile)
- If the destination is a directory specification, the file name will be the same as the source.
Parameters
| Name | Type | Description |
|---|---|---|
srcFile |
File |
source file |
destFile |
File |
destination file (directory specification allowed) |
Return Value
File - the destination file object
delete
public boolean delete(String deleteFilePath)
- Returns
falseif the file does not exist.
Parameters
| Name | Type | Description |
|---|---|---|
deleteFilePath |
String |
file path to delete |
Return Value
boolean - false if the file does not exist
delete
public boolean delete(File deleteFile)
Parameters
| Name | Type | Description |
|---|---|---|
deleteFile |
File |
file to delete |
Return Value
boolean - false if the file does not exist
See Also
makeDir
public boolean makeDir(String dirPath)
Parameters
| Name | Type | Description |
|---|---|---|
dirPath |
String |
directory path |
Return Value
boolean - false if it already exists