- private static void uncheckedClose(Closeable closeable) {
- try {
- if (closeable != null)
- closeable.close();
- } catch (IOException e) {
- //ignore
- }
- }
-
- private static File copyResource(URL url, File targetFile) throws IOException, FileNotFoundException {
- FileOutputStream os = null;
- InputStream is = null;
- try {
- if (targetFile.exists())
- targetFile.delete();
-
- is = url.openStream();
- int read;
- byte [] buffer = new byte [16384];
- os = new FileOutputStream (targetFile);
- while ((read = is.read (buffer)) != -1) {
- os.write(buffer, 0, read);
- }
- os.close ();
- is.close ();
-
- return targetFile;
- } finally {
- uncheckedClose(os);
- uncheckedClose(is);
- }
- }
-
- private static File extractLib(URL libURL, String libName) throws FileNotFoundException, IOException {
- String tmpDirStr = System.getProperty("java.io.tmpdir");
- if (tmpDirStr == null)
- throw new NullPointerException("java.io.tmpdir property is null");
- File tmpDir = new File(tmpDirStr);
- File libFile = new File(tmpDir, libName);
- return copyResource(libURL, libFile);
- }
-
- private static File url2file(URL url, String fileName) {
+ private static File extractLib(URL libURL, String libName) throws FileNotFoundException, IOException {
+ String tmpDirStr = System.getProperty("java.io.tmpdir");
+ if (tmpDirStr == null)
+ throw new NullPointerException("java.io.tmpdir property is null");
+ File tmpDir = new File(tmpDirStr);
+ File libFile = new File(tmpDir, libName);
+ return copyResource(libURL, libFile);
+ }
+
+ private static File url2file(URL url, String fileName) {