public class FileManager extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
FileManager.FileFilter |
static interface |
FileManager.JarFileFilter |
Constructor and Description |
---|
FileManager() |
Modifier and Type | Method and Description |
---|---|
static boolean |
buildJar(String targetJar,
String[] jars,
String[] files,
String[] prefixs,
FileManager.JarFileFilter filter) |
static boolean |
checkJarContent(String jarPath,
String jarContent) |
static String |
convertStreamToString(InputStream is) |
static File |
createTempDir() |
static File |
createTempDir(String path) |
static File |
createTempFile(String suffix) |
static File |
createTempFile(String suffix,
String path) |
static boolean |
deleteFileOrFolder(File fPath) |
static boolean |
deleteFileOrFolder(File fPath,
FileManager.FileFilter filter) |
static boolean |
deleteFileOrFolder(String fpPath) |
static boolean |
deleteFileOrFolder(String fpPath,
FileManager.FileFilter filter) |
static void |
deleteNotUsedImages(String bundle,
Set<String> usedImages) |
static void |
deleteTempDir(String path) |
static String |
downloadURL(String url,
String localPath)
download a file at the given url to a local folder
|
static String |
downloadURL(String url,
String localPath,
JFrame progress) |
static String |
downloadURL(URL url,
String localPath)
download a file at the given url to a local folder
|
static String |
downloadURLtoString(String src) |
static String |
downloadURLtoString(URL uSrc) |
static boolean |
exists(String path) |
static boolean |
extractResource(String src,
File tgt) |
static String |
extractResourceAsLines(String src) |
static String |
getAddress(String arg) |
static String |
getAltFilename(String filename) |
static String |
getJarName(Class cname) |
static String |
getJarParentFolder() |
static String |
getJarPath(Class cname) |
static String |
getName(String filename) |
static int |
getPort(String p) |
static Proxy |
getProxy() |
static InetAddress |
getProxyAddress(String arg) |
static int |
getProxyPort(String p) |
static int |
getRandomInt() |
static File[] |
getScriptFile(File fScriptFolder) |
static URL |
getURLForContentFromURL(URL uRes,
String fName) |
static boolean |
isBundle(String dir) |
static boolean |
isFilenameDotted(String name) |
static int |
isUrlUseabel(String sURL) |
static int |
isUrlUseabel(URL aURL) |
static String |
makeFileList(File path,
String prefix) |
static URL |
makeURL(String fName) |
static URL |
makeURL(String fName,
String type) |
static URL |
makeURL(URL path,
String fName) |
static void |
mkdir(String path) |
static String |
normalize(String filename) |
static String |
normalizeAbsolute(String filename,
boolean withTrailingSlash) |
static boolean |
openURL(String url)
open the given url in the standard browser
|
static boolean |
packJar(String folderName,
String jarName,
String prefix) |
static boolean |
pathEquals(String path1,
String path2)
compares to path strings using java.io.File.equals()
|
static String |
readFileToString(File fPath) |
static void |
resetFolder(File fPath) |
static File |
resolveImagePath(File scriptFile)
Returns the directory that contains the images used by the ScriptRunner.
|
static String |
saveImage(BufferedImage img,
String sImage,
String bundlePath) |
static String |
saveTimedImage(BufferedImage img) |
static String |
saveTimedImage(BufferedImage img,
String path) |
static String |
saveTimedImage(BufferedImage img,
String path,
String name) |
static String |
saveTmpImage(BufferedImage img) |
static String |
saveTmpImage(BufferedImage img,
String path) |
static boolean |
setProxy(String pName,
String pPort) |
static String |
slashify(String path,
Boolean isDirectory) |
static File |
smartCopy(String src,
String dest)
Copy a file *src* to the path *dest* and check if the file name conflicts.
|
static void |
traverseFolder(File fPath,
FileManager.FileFilter filter) |
static int |
tryGetFileSize(URL aUrl) |
static boolean |
unpackJar(String jarName,
String folderName,
boolean del,
boolean strip,
FileManager.JarFileFilter filter)
unpack a jar file to a folder
|
static boolean |
unzip(File fZip,
File fTarget) |
static boolean |
unzip(String inpZip,
String target) |
static String |
unzipSKL(String fpSkl) |
static boolean |
writeStringToFile(String text,
File fPath) |
static boolean |
writeStringToFile(String text,
String path) |
static boolean |
xcopy(File fSrc,
File fDest) |
static boolean |
xcopy(File fSrc,
File fDest,
FileManager.FileFilter filter) |
static void |
xcopy(String src,
String dest) |
static void |
xcopy(String src,
String dest,
FileManager.FileFilter filter) |
static void |
zip(String path,
String outZip) |
public static int tryGetFileSize(URL aUrl)
public static int isUrlUseabel(String sURL)
public static int isUrlUseabel(URL aURL)
public static Proxy getProxy()
public static String downloadURL(URL url, String localPath)
url
- a valid urllocalPath
- the folder where the file should go (will be created if necessary)public static String downloadURL(String url, String localPath)
url
- a string representing a valid urllocalPath
- the folder where the file should go (will be created if necessary)public static boolean openURL(String url)
url
- string representing a valid urlpublic static File createTempDir()
public static int getRandomInt()
public static void deleteTempDir(String path)
public static boolean deleteFileOrFolder(File fPath, FileManager.FileFilter filter)
public static boolean deleteFileOrFolder(File fPath)
public static boolean deleteFileOrFolder(String fpPath, FileManager.FileFilter filter)
public static boolean deleteFileOrFolder(String fpPath)
public static void resetFolder(File fPath)
public static void traverseFolder(File fPath, FileManager.FileFilter filter)
public static String saveTmpImage(BufferedImage img)
public static String saveTmpImage(BufferedImage img, String path)
public static String saveTimedImage(BufferedImage img)
public static String saveTimedImage(BufferedImage img, String path)
public static String saveTimedImage(BufferedImage img, String path, String name)
public static boolean xcopy(File fSrc, File fDest, FileManager.FileFilter filter)
public static void xcopy(String src, String dest) throws IOException
IOException
public static void xcopy(String src, String dest, FileManager.FileFilter filter) throws IOException
IOException
public static File smartCopy(String src, String dest) throws IOException
src
- source filedest
- destination pathIOException
- on failurepublic static String convertStreamToString(InputStream is)
public static boolean exists(String path)
public static void mkdir(String path)
public static String normalizeAbsolute(String filename, boolean withTrailingSlash)
public static boolean isFilenameDotted(String name)
public static File resolveImagePath(File scriptFile)
scriptFile
- The file containing the script.public static int getPort(String p)
public static int getProxyPort(String p)
public static InetAddress getProxyAddress(String arg)
public static String saveImage(BufferedImage img, String sImage, String bundlePath)
public static void zip(String path, String outZip) throws IOException, FileNotFoundException
IOException
FileNotFoundException
public static boolean isBundle(String dir)
public static String getJarParentFolder()
public static boolean buildJar(String targetJar, String[] jars, String[] files, String[] prefixs, FileManager.JarFileFilter filter)
public static boolean unpackJar(String jarName, String folderName, boolean del, boolean strip, FileManager.JarFileFilter filter)
jarName
- absolute path to jar filefolderName
- absolute path to the target folderdel
- true if the folder should be deleted before unpackstrip
- true if the path should be strippedfilter
- to select specific content