All Downloads are FREE. Search and download functionalities are using the official Maven repository.

redis.embedded.util.JarUtil Maven / Gradle / Ivy

There is a newer version: 0.11.0
Show newest version
package redis.embedded.util;

import com.google.common.io.Files;
import com.google.common.io.Resources;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class JarUtil {

    public static File extractExecutableFromJar(String executable) throws IOException {
        File tmpDir = Files.createTempDir();
        tmpDir.deleteOnExit();

        File command = new File(tmpDir, executable);
        FileUtils.copyURLToFile(Resources.getResource(executable), command);
        command.deleteOnExit();
        if ( ! command.setExecutable(true)) {
            throw new IOException("Failed to set execute permission on " + command.getAbsolutePath());
        }
        return command;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy