java/hybridse-sdk/src/main/java/com/_4paradigm/hybridse/LibraryLoader.java
public static String extractResource(String path, boolean isTemp) throws IOException {
        InputStream inputStream = LibraryLoader.class.getClassLoader().getResourceAsStream(path);
        if (inputStream != null) {
            logger.info("Found {} in local resource", path);
            File localFile;
            if (isTemp) {
                String suffix = path.replace("/", "-"); // do not make temp directory
                localFile = File.createTempFile("temp-", suffix);
            } else {
                localFile = new File("./", path);
                if (localFile.exists()) {
                    logger.warn("Existing path {}, will overwrite", localFile.getPath());
                }
                File parent = localFile.getParentFile();
                if (parent != null && !parent.exists()) {
                    parent.mkdirs();
                }
            }
            localFile.deleteOnExit();
            String absolutePath = localFile.getAbsolutePath();
            try (FileOutputStream outputStream = new FileOutputStream(absolutePath)) {
                IOUtils.copy(inputStream, outputStream);
                return absolutePath;
            }
        } else {
            throw new IOException(String.format("Can not find %s in local resource", path));
        }
    }
/**
     * Extract library in resource into filesystem.
     *
     * @param path Local resource path
     * @param isTemp If extract to template file
     * @return Return the absolute path of resource
     * @throws IOException throw when IO Exception
     */
Extract library in resource into filesystem.
@param path Local resource path
@param isTemp If extract to template file
@return Return the absolute path of resource
@throws IOException throw when IO Exception
Extract library in resource into filesystem . @param path Local resource path @param isTemp If extract to template file @return Return the absolute path of resource @throws IOException throw when IO Exception
public static String extractResource(String path, boolean isTemp) throws IOException {
        InputStream inputStream = LibraryLoader.class.getClassLoader().getResourceAsStream(path);
        if (inputStream != null) {
            logger.info("Found {} in local resource", path);
            File localFile;
            if (isTemp) {
                String suffix = path.replace("/", "-"); 
                localFile = File.createTempFile("temp-", suffix);
            } else {
                localFile = new File("./", path);
                if (localFile.exists()) {
                    logger.warn("Existing path {}, will overwrite", localFile.getPath());
                }
                File parent = localFile.getParentFile();
                if (parent != null && !parent.exists()) {
                    parent.mkdirs();
                }
            }
            localFile.deleteOnExit();
            String absolutePath = localFile.getAbsolutePath();
            try (FileOutputStream outputStream = new FileOutputStream(absolutePath)) {
                IOUtils.copy(inputStream, outputStream);
                return absolutePath;
            }
        } else {
            throw new IOException(String.format("Can not find %s in local resource", path));
        }
    }
public static String extractResource ( String path , boolean isTemp ) throws IOException { InputStream inputStream = LibraryLoader . class . getClassLoader ( ) . getResourceAsStream ( path ) ; if ( inputStream != null ) { logger . info ( "Found {} in local resource" , path ) ; File localFile ; if ( isTemp ) { String suffix = path . replace ( "/" , "-" ) ; localFile = File . createTempFile ( "temp-" , suffix ) ; } else { localFile = new File ( "./" , path ) ; if ( localFile . exists ( ) ) { logger . warn ( "Existing path {}, will overwrite" , localFile . getPath ( ) ) ; } File parent = localFile . getParentFile ( ) ; if ( parent != null && ! parent . exists ( ) ) { parent . mkdirs ( ) ; } } localFile . deleteOnExit ( ) ; String absolutePath = localFile . getAbsolutePath ( ) ; try ( FileOutputStream outputStream = new FileOutputStream ( absolutePath ) ) { IOUtils . copy ( inputStream , outputStream ) ; return absolutePath ; } } else { throw new IOException ( String . format ( "Can not find %s in local resource" , path ) ) ; } }
Extract library in resource into filesystem.
Extract library in resource into filesystem .
// do not make temp directory