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 |
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
|
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) |
void |
openBufferedAppend()
Opens a buffered file for append
|
void |
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
|
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 void setFileName(java.lang.String pathname)
pathname
- public void setFile(java.io.File file)
file
- public java.io.File getFile()
public void closeFile()
public void setFileFilter(java.lang.String filter)
filter
- public java.lang.String getFileFilter()
public static java.lang.String getSeparator()
public boolean createFolder()
public static boolean createFolder(java.lang.String path)
path
- The location of the new folderpublic boolean createFile()
public java.io.File[] getFileList()
public void deleteFileList(java.io.File[] files)
files
- public static boolean deleteFolder(java.lang.String folder)
folder
- public static void secureWipeFolder(java.lang.String folder)
folder
- public static void secureWipeFolder(java.io.File folder)
folder
- public static void secureWipe(java.lang.String filename)
filename
- public static void secureWipe(java.io.File f)
f
- public static java.io.File renameTo(java.io.File f, java.lang.String newname)
public static void copyFolderContents(java.lang.String from, java.lang.String to, java.lang.String ignore)
from
- The from pathto
- The to pathignore
- public java.lang.String[] getFilenames(int offset)
offset
- public boolean exists()
public static boolean exists(java.lang.String pathname)
pathname
- The pathname to check forpublic boolean delete()
public static boolean delete(java.lang.String filename)
filename
- public boolean renameFile(java.lang.String toname)
toname
- public void openBufferedRead()
public void openBufferedResource()
public void openBufferedAppend()
public java.lang.String readLine()
public java.lang.String readEntireFile()
public java.io.FileInputStream openFileInputStream(java.lang.String filename)
public java.io.FileOutputStream openFileOutputStream()
public void openBufferedWrite()
public void flushWriter()
public void writeFile(java.lang.String data, int newlines)
data
- The data to be writtennewlines
- The number of newlines to generatepublic void writeFile(char[] data, int nochars)
data
- The character data to be writtennochars
- public static void copyFromTo(java.lang.String frompath, java.lang.String topath)
frompath
- topath
- public static void mergeFiles(java.lang.String srcpath1, java.lang.String srcpath2, java.lang.String destpath)
public static float getAgeOfFile(java.lang.String filepath, int period)
filepath
- period
- public static boolean isMinutesOlder(java.lang.String filename, long minutes)
filename
- minutes
- public static boolean isHoursOlder(java.lang.String filename, long hours)
filename
- hours
- public static boolean isDaysOlder(java.lang.String filename, long days)
filename
- days
- public boolean openZipStream(int level)
level
- public void closeZipStream()
public boolean addFilesToZip(java.io.File... srcfiles)
srcfiles
- An array of Filespublic boolean extractZipTo(java.lang.String destpath)
destpath
- Destination for contents of zip file