public class FileLoader
extends java.lang.Object
Constructor and Description |
---|
FileLoader()
Create a new instance of FileLoader
|
Modifier and Type | Method and Description |
---|---|
static void |
copyStream(java.io.File sourceFile,
java.io.File destFile)
Copy the source input stream contents to the destination file.
|
static void |
deleteFile(java.lang.String fileName)
Delete the file at the specified file path.
|
static void |
deleteFolder(java.lang.String folderName)
Delete the folder and all contained files recursively, at the specified path.
|
static boolean |
exists(java.lang.String path)
Return true if the path exists.
|
static java.io.BufferedReader |
getBufferedInputStream(java.lang.String fileName)
Get the contents of the file as a buffered reader.
|
static java.lang.String |
getCurrentDirectory()
Get the current directory the program is running in.
|
static java.io.DataInputStream |
getDataInputStream(java.lang.String fileName)
Get the stream connector to the file.
|
static java.io.DataOutputStream |
getDataOutputStream(java.lang.String fileName)
Get an output stream to a (probably local) file.
|
static java.util.ArrayList<java.lang.String> |
getDirectoryList(java.lang.String dirPath)
Get the list of directories stored in the specified directory.
|
static java.util.ArrayList<java.lang.String> |
getFileList(java.lang.String dirPath)
Get the list of files stored in the specified directory.
|
static java.util.ArrayList<java.lang.String> |
getFileList(java.lang.String dirPath,
boolean subFolders)
Get the list of files stored in the specified directory.
|
static java.util.ArrayList<java.lang.String> |
getFullDirectoryListPaths(java.lang.String dirPath)
Get the list of directories stored in the specified directory, as full file paths.
|
static java.util.ArrayList<java.lang.String> |
getFullFileListPaths(java.lang.String dirPath)
Get the list of files stored in the specified directory.
|
static java.util.ArrayList<java.lang.String> |
getFullFileListPaths(java.lang.String dirPath,
boolean subFolders)
Get the list of files stored in the specified directory.
|
static java.lang.String |
getInputStream(java.lang.String fileName)
Get the contents of the file as a String.
|
static java.io.BufferedReader |
loadFile(java.io.File filePath)
Load a file and store in a buffer.
|
public static java.lang.String getInputStream(java.lang.String fileName) throws java.lang.Exception
fileName
- the name and location of the file to load.java.lang.Exception
- any error.public static java.io.DataInputStream getDataInputStream(java.lang.String fileName) throws java.lang.Exception
fileName
- the name and location of the file to load.java.lang.Exception
- any error.public static java.io.BufferedReader getBufferedInputStream(java.lang.String fileName) throws java.lang.Exception
fileName
- the name and location of the file to load. This could be
at a remote location.java.lang.Exception
- any error.public static java.io.DataOutputStream getDataOutputStream(java.lang.String fileName)
fileName
- the name and location of the file to load.public static java.io.BufferedReader loadFile(java.io.File filePath) throws java.lang.Exception
filePath
- the path of the file to read.java.lang.Exception
- any error.public static java.lang.String getCurrentDirectory() throws java.lang.Exception
java.lang.Exception
- any errorpublic static java.util.ArrayList<java.lang.String> getDirectoryList(java.lang.String dirPath)
dirPath
- the directory path.public static java.util.ArrayList<java.lang.String> getFullDirectoryListPaths(java.lang.String dirPath)
dirPath
- the directory path.public static java.util.ArrayList<java.lang.String> getFileList(java.lang.String dirPath) throws java.lang.Exception
dirPath
- the directory path.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getFileList(java.lang.String dirPath, boolean subFolders) throws java.lang.Exception
dirPath
- the directory path.subFolders
- if true include all files in all sub-folders, if false include
files in the current folder only.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getFullFileListPaths(java.lang.String dirPath) throws java.lang.Exception
dirPath
- the directory path.java.lang.Exception
- any error.public static java.util.ArrayList<java.lang.String> getFullFileListPaths(java.lang.String dirPath, boolean subFolders) throws java.lang.Exception
dirPath
- the directory path.subFolders
- if true include all files in all sub-folders, if false include
files in the current folder only.java.lang.Exception
- any error.public static void copyStream(java.io.File sourceFile, java.io.File destFile) throws java.lang.Exception
sourceFile
- the file to copy.destFile
- the file path to copy tojava.lang.Exception
- any error.public static boolean exists(java.lang.String path)
path
- a file or folder path.public static void deleteFile(java.lang.String fileName) throws java.lang.Exception
fileName
- the name of the file to delete.java.lang.Exception
public static void deleteFolder(java.lang.String folderName) throws java.lang.Exception
folderName
- the name of the outermost folder to delete.java.lang.Exception
- any error