redis.embedded.util.JarUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of embedded-redis Show documentation
Show all versions of embedded-redis Show documentation
Redis embedded server for Java integration testing
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