Class FileManager


  • public class FileManager
    extends Object
    INTERNAL USE: Support for accessing files and other ressources
    • Constructor Detail

      • FileManager

        public FileManager()
    • Method Detail

      • isUrlUseabel

        public static int isUrlUseabel​(String sURL)
      • isUrlUseabel

        public static int isUrlUseabel​(URL aURL)
      • getProxy

        public static Proxy getProxy()
      • getProxyPort

        public static int getProxyPort​(String p)
      • setProxy

        public static boolean setProxy​(String pName,
                                       String pPort)
      • downloadURL

        public static String downloadURL​(URL url,
                                         String localPath)
        download a file at the given url to a local folder
        Parameters:
        url - a valid url
        localPath - the folder where the file should go (will be created if necessary)
        Returns:
        the absolute path to the downloaded file or null on any error
      • downloadURL

        public static String downloadURL​(String url,
                                         String localPath)
        download a file at the given url to a local folder
        Parameters:
        url - a string representing a valid url
        localPath - the folder where the file should go (will be created if necessary)
        Returns:
        the absolute path to the downloaded file or null on any error
      • downloadURLtoString

        public static String downloadURLtoString​(String src)
      • downloadURLtoString

        public static String downloadURLtoString​(URL uSrc)
      • downloadURLtoString

        public static String downloadURLtoString​(URL uSrc,
                                                 boolean silent)
      • openURL

        public static boolean openURL​(String url)
        open the given url in the standard browser
        Parameters:
        url - string representing a valid url
        Returns:
        false on error, true otherwise
      • createTempDir

        public static File createTempDir​(String path)
      • createTempDir

        public static File createTempDir()
      • getRandomInt

        public static int getRandomInt()
      • deleteTempDir

        public static void deleteTempDir​(String path)
      • deleteFileOrFolder

        public static boolean deleteFileOrFolder​(File fPath)
      • deleteFileOrFolder

        public static boolean deleteFileOrFolder​(String fpPath)
      • resetFolder

        public static void resetFolder​(File fPath)
      • createTempFile

        public static File createTempFile​(String suffix)
      • createTempFile

        public static File createTempFile​(String suffix,
                                          String path)
      • unzip

        public static boolean unzip​(String inpZip,
                                    String target)
      • unzip

        public static boolean unzip​(File fZip,
                                    File fTarget)
      • xcopy

        public static boolean xcopy​(File fSrc,
                                    File fDest)
      • makeFileList

        public static String makeFileList​(File path,
                                          String prefix)
      • smartCopy

        public static File smartCopy​(String src,
                                     String dest)
                              throws IOException
        Copy a file *src* to the path *dest* and check if the file name conflicts. If a file with the same name exists in that path, rename *src* to an alternative name.
        Parameters:
        src - source file
        dest - destination path
        Returns:
        the destination file if ok, null otherwise
        Throws:
        IOException - on failure
      • convertStreamToString

        public static String convertStreamToString​(InputStream is)
      • getAltFilename

        public static String getAltFilename​(String filename)
      • exists

        public static boolean exists​(String path)
      • mkdir

        public static void mkdir​(String path)
      • getName

        public static String getName​(String filename)
      • normalize

        public static String normalize​(String path)
      • normalizeAbsolute

        public static String normalizeAbsolute​(String filename)
      • isFilenameDotted

        public static boolean isFilenameDotted​(String name)
      • resolveImagePath

        public static File resolveImagePath​(File scriptFile)
        Returns the directory that contains the images used by the ScriptRunner.
        Parameters:
        scriptFile - The file containing the script.
        Returns:
        The directory containing the images.
      • makeURL

        public static URL makeURL​(String fName)
      • makeJarURL

        public static URL makeJarURL​(File fJar)
      • makeURL

        public static URL makeURL​(URL path,
                                  String fName)
      • getURLForContentFromURL

        public static URL getURLForContentFromURL​(URL uRes,
                                                  String fName)
      • checkJarContent

        public static boolean checkJarContent​(String jarPath,
                                              String jarContent)
      • getPort

        public static int getPort​(String p)
      • getAddress

        public static String getAddress​(String arg)
      • deleteNotUsedImages

        public static void deleteNotUsedImages​(String bundle,
                                               Set<String> usedImages)
      • isBundle

        public static boolean isBundle​(String dir)
      • getJarPath

        public static String getJarPath​(Class cname)
      • getJarName

        public static String getJarName​(Class cname)
      • writeStringToFile

        public static boolean writeStringToFile​(String text,
                                                String path)
      • writeStringToFile

        public static boolean writeStringToFile​(String text,
                                                File fPath)
      • readFileToString

        public static String readFileToString​(File fPath)
      • packJar

        public static boolean packJar​(String folderName,
                                      String jarName,
                                      String prefix)
      • buildJar

        public static boolean buildJar​(String targetJar,
                                       String[] jars,
                                       String[] files,
                                       String[] prefixs,
                                       org.sikuli.basics.FileManager.JarFileFilter filter)
      • unpackJar

        public static boolean unpackJar​(String jarName,
                                        String folderName,
                                        boolean del,
                                        boolean strip,
                                        org.sikuli.basics.FileManager.JarFileFilter filter)
        unpack a jar file to a folder
        Parameters:
        jarName - absolute path to jar file
        folderName - absolute path to the target folder
        del - true if the folder should be deleted before unpack
        strip - true if the path should be stripped
        filter - to select specific content
        Returns:
        true if success, false otherwise
      • unzipSKL

        public static String unzipSKL​(String fpSkl)
      • pathEquals

        public static boolean pathEquals​(String path1,
                                         String path2)