70 if (!path.startsWith(
"/")) {
71 throw new IllegalArgumentException(
"The path has to be absolute (start with '/').");
75 String[] parts = path.split(
"/");
76 String filename = (parts.length > 1) ? parts[parts.length - 1] :
null;
81 if (filename !=
null) {
82 parts = filename.split(
"\\.", 2);
84 suffix = (parts.length > 1) ?
"." + parts[parts.length - 1] :
null;
88 if (filename ==
null || prefix.length() < 3) {
89 throw new IllegalArgumentException(
"The filename has to be at least 3 characters long.");
93 File temp = File.createTempFile(prefix, suffix);
97 throw new FileNotFoundException(
"File " + temp.getAbsolutePath() +
" does not exist.");
101 byte[] buffer =
new byte[1024];
105 InputStream is = NativeUtils.class.getResourceAsStream(path);
107 throw new FileNotFoundException(
"File " + path +
" was not found inside JAR.");
112 OutputStream os =
new FileOutputStream(temp);
114 while ((readBytes = is.read(buffer)) != -1) {
115 os.write(buffer, 0, readBytes);
124 System.load(temp.getAbsolutePath());