public class SimpleFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
FILEDELETEFAIL |
static int |
FILEDELETEOK |
static int |
NOTFOUND |
static int |
PERIOD_DAYS |
static int |
PERIOD_HOURS |
static int |
PERIOD_MINUTES |
Constructor and Description |
---|
SimpleFile() |
SimpleFile(java.lang.String pathname)
Constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
addFilesToZip(java.io.File... srcfiles)
Add files to a zip file
|
void |
closeFile()
Close file and any resources such as buffered readers/writers that are
attached to it.
|
void |
closeZipStream()
Close a zip stream
|
static void |
compress(java.lang.String source,
java.lang.String dest) |
static void |
copyFolderContents(java.lang.String from,
java.lang.String to,
java.lang.String ignore)
Copy multiple files from one folder to another
|
static void |
copyFromTo(java.lang.String frompath,
java.lang.String topath)
Copy file to
|
boolean |
createFile()
Create a new file
|
boolean |
createFolder()
Creates a new folder
|
static boolean |
createFolder(java.lang.String path)
Creates a new folder
|
boolean |
delete()
Deletes file
|
static boolean |
delete(java.lang.String filename)
Deletes the specified file
|
void |
deleteFileList(java.io.File[] files)
Deletes the supplied list of files, be very carefull with this
|
static boolean |
deleteFolder(java.lang.String folder)
Delete folder and its contents using specified folder path
|
boolean |
exists()
Test to see if path exists
|
static boolean |
exists(java.lang.String pathname)
Test to see if path exists
|
boolean |
extractZipTo(java.lang.String destpath)
Extracts a zip file to a supplied location
|
void |
flushWriter() |
static float |
getAgeOfFile(java.lang.String filepath,
int period)
Get the age of a specified file
|
java.io.File |
getFile()
Get file
|
java.lang.String |
getFileFilter()
Gets the current file filter
|
java.io.File[] |
getFileList()
Gets the file list at the specified directory location based on filter
contents
|
java.lang.String[] |
getFilenames(int offset)
Returns an array of filenames, array if populated from the offset value
onwards
|
java.io.File |
getOldestFile() |
static java.lang.String |
getSeparator() |
static boolean |
isDaysOlder(java.lang.String filename,
long days)
Test to see our file is older in days, returns true if it is
|
static boolean |
isHoursOlder(java.lang.String filename,
long hours)
Test to see our file is older in hours, returns true if it is
|
static boolean |
isMinutesOlder(java.lang.String filename,
long minutes)
Test to see our file is older in minutes, returns true if it is
|
static void |
mergeFiles(java.lang.String srcpath1,
java.lang.String srcpath2,
java.lang.String destpath) |
static java.lang.Object |
objectRead(java.lang.String filepath,
java.lang.Object defObject) |
static boolean |
objectWrite(java.lang.String filepath,
java.lang.Object o) |
void |
openBufferedAppend()
Opens a buffered file for append
|
java.io.BufferedReader |
openBufferedRead()
Opens a buffered file for read
|
void |
openBufferedResource()
Use this if you need access to a file within a jar
|
void |
openBufferedWrite()
Opens a buffered file for write
|
java.io.FileInputStream |
openFileInputStream(java.lang.String filename) |
java.io.FileOutputStream |
openFileOutputStream()
Opens a file output stream
|
boolean |
openZipStream(int level)
Opens a zipstream.
|
java.lang.String |
readEntireFile()
Read bytes from previously opened BufferedReader
|
java.lang.String |
readLine()
Read a single line from a text file
|
boolean |
renameFile(java.lang.String toname) |
static java.io.File |
renameTo(java.io.File f,
java.lang.String newname) |
static void |
secureWipe(java.io.File f)
Wipe file using specified File
|
static void |
secureWipe(java.lang.String filename)
Wipe file using specified filename
|
static void |
secureWipeFolder(java.io.File folder)
Wipe folder and its contents using specified File
|
static void |
secureWipeFolder(java.lang.String folder)
Wipe folder and its contents using specified folder path
|
void |
setFile(java.io.File file)
Set file
|
void |
setFileFilter(java.lang.String filter)
Sets the file filter
|
void |
setFileName(java.lang.String pathname)
Set filename
|
static void |
walkFileTree(java.lang.String path,
java.util.ArrayList<java.io.File> files) |
static void |
walkFileTree(java.lang.String path,
java.util.ArrayList<java.io.File> files,
java.lang.String filter) |
void |
writeFile(char[] data,
int nochars)
Write to a previously opened output file
|
void |
writeFile(java.lang.String data,
int newlines)
Write to a previously opened output file
|
public static final int PERIOD_MINUTES
public static final int PERIOD_HOURS
public static final int PERIOD_DAYS
public static final int NOTFOUND
public static final int FILEDELETEOK
public static final int FILEDELETEFAIL
public SimpleFile()
public SimpleFile(java.lang.String pathname)
pathname
- public final void setFileName(java.lang.String pathname)
pathname
- public final void setFile(java.io.File file)
file
- public final java.io.File getFile()
public final void closeFile()
public final void setFileFilter(java.lang.String filter)
filter
- public final java.lang.String getFileFilter()
public static final java.lang.String getSeparator()
public final boolean createFolder()
public static final boolean createFolder(java.lang.String path)
path
- The location of the new folderpublic final boolean createFile()
public final java.io.File[] getFileList()
public final java.io.File getOldestFile()
public static final void walkFileTree(java.lang.String path, java.util.ArrayList<java.io.File> files)
public static final void walkFileTree(java.lang.String path, java.util.ArrayList<java.io.File> files, java.lang.String filter)
public final void deleteFileList(java.io.File[] files)
files
- public static final boolean deleteFolder(java.lang.String folder)
folder
- public static final void secureWipeFolder(java.lang.String folder)
folder
- public static final void secureWipeFolder(java.io.File folder)
folder
- public static final void secureWipe(java.lang.String filename)
filename
- public static final void secureWipe(java.io.File f)
f
- public static final java.io.File renameTo(java.io.File f, java.lang.String newname)
public static final void copyFolderContents(java.lang.String from, java.lang.String to, java.lang.String ignore)
from
- The from pathto
- The to pathignore
- public final java.lang.String[] getFilenames(int offset)
offset
- public final boolean exists()
public static final boolean exists(java.lang.String pathname)
pathname
- The pathname to check forpublic final boolean delete()
public static final boolean delete(java.lang.String filename)
filename
- public final boolean renameFile(java.lang.String toname)
toname
- public final java.io.BufferedReader openBufferedRead()
public final void openBufferedResource()
public final void openBufferedAppend()
public final java.lang.String readLine()
public final java.lang.String readEntireFile()
public final java.io.FileInputStream openFileInputStream(java.lang.String filename)
public final java.io.FileOutputStream openFileOutputStream()
public final void openBufferedWrite()
public final void flushWriter()
public final void writeFile(java.lang.String data, int newlines)
data
- The data to be writtennewlines
- The number of newlines to generatepublic final void writeFile(char[] data, int nochars)
data
- The character data to be writtennochars
- public static final void copyFromTo(java.lang.String frompath, java.lang.String topath)
frompath
- topath
- public static final void mergeFiles(java.lang.String srcpath1, java.lang.String srcpath2, java.lang.String destpath)
public static final float getAgeOfFile(java.lang.String filepath, int period)
filepath
- period
- public static final boolean isMinutesOlder(java.lang.String filename, long minutes)
filename
- minutes
- public static final boolean isHoursOlder(java.lang.String filename, long hours)
filename
- hours
- public static final boolean isDaysOlder(java.lang.String filename, long days)
filename
- days
- public final boolean openZipStream(int level)
level
- public final void closeZipStream()
public static final void compress(java.lang.String source, java.lang.String dest)
public final boolean addFilesToZip(java.io.File... srcfiles)
srcfiles
- An array of Filespublic final boolean extractZipTo(java.lang.String destpath)
destpath
- Destination for contents of zip filepublic static final boolean objectWrite(java.lang.String filepath, java.lang.Object o)
public static final java.lang.Object objectRead(java.lang.String filepath, java.lang.Object defObject)