public class OAFile extends File
Note: All file names separators will automatically be converted to match the Operating System.
Modifier and Type | Field and Description |
---|---|
static String |
FS |
static String |
NL |
pathSeparator, pathSeparatorChar, separator, separatorChar
Modifier and Type | Method and Description |
---|---|
static String |
convertFileName(String fileName)
Converts fileName path to correct system file.separator characters.
|
static String |
convertFileName(String fileName,
boolean bEndWithSlashChar)
Converts fileName path to correct system file.separator characters.
|
static void |
copy(File file,
File fileTo) |
static void |
copy(String fileNameFrom,
String fileNameTo)
Copy a file to another file.
|
static boolean |
copyResourceToFile(Class c,
String resourceName,
String fname)
Copy a file from class/jar to file.
|
boolean |
copyTo(OAFile fileTo)
Copy this file to another file.
|
boolean |
copyTo(String fileNameTo)
Copy this file to another file.
|
static void |
delTree(File f) |
static String |
getDirectoryName(String filePath) |
static String |
getExtension(File file) |
static String |
getExtension(String filePath) |
static String |
getFileName(String filePath) |
void |
mkdirsForFile()
Create all directories for fileName.
|
static void |
mkdirsForFile(File file) |
static void |
mkdirsForFile(String fileName)
Create directories for fileName.
Compared to the method in the File.class, "File.mkdirs()" which creates a directory using the full fileName, where fileName itself will end up being a directory. |
static String[] |
readResourceTextFile(Class c,
String resourceName)
Read the contents of a text file from a specific class location.
|
static String |
readTextFile(Class c,
String fname,
int estimatedSize)
Read the contents of a text file from a specific class location.
|
static String |
readTextFile(File file,
int estimatedSize) |
static String |
readTextFile(String fname,
int estimatedSize) |
static void |
removeDir(File f) |
void |
renameTo(String fileName)
Renames this file to another name.
|
static void |
rmDir(File f)
Remove directory and all children files.
|
static boolean |
writeTextFile(File file,
String data) |
static boolean |
writeTextFile(String fname,
String data) |
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
public OAFile(String fname)
public boolean copyTo(String fileNameTo)
copy(String,String)
public boolean copyTo(OAFile fileTo)
copy(String,String)
public void mkdirsForFile()
public static String convertFileName(String fileName)
public static String convertFileName(String fileName, boolean bEndWithSlashChar)
public static void mkdirsForFile(String fileName)
public static void mkdirsForFile(File file)
public void renameTo(String fileName)
public static void copy(String fileNameFrom, String fileNameTo) throws Exception
NOTE: if the fileNameTo already exists, it will be overwritten.
Exception
public static boolean copyResourceToFile(Class c, String resourceName, String fname) throws Exception
c
- resourceName
- class path name for file to read
param fname
file name to save as
param estimatedSizeException
public static String[] readResourceTextFile(Class c, String resourceName) throws Exception
Exception
public static String readTextFile(Class c, String fname, int estimatedSize) throws Exception
fname
- '/' seperated file name, located from the class. If fname
begins with '/' then the file will go to the root directory.Exception
public static String readTextFile(File file, int estimatedSize) throws Exception
Exception
public static String readTextFile(String fname, int estimatedSize) throws Exception
Exception
public static boolean writeTextFile(String fname, String data) throws Exception
Exception
public static boolean writeTextFile(File file, String data) throws Exception
Exception
public static void rmDir(File f) throws IOException
IOException
public static void removeDir(File f) throws IOException
IOException
public static void delTree(File f) throws IOException
IOException
Copyright © 1999–2019 ViaOA. All rights reserved.