diff --git a/pom.xml b/pom.xml
index c35b2fac..6496841d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
Jansi is a java library for generating and interpreting ANSI escape sequences.
- 6
+ 7
1.7
UTF-8
1.6.1
diff --git a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
index 2637c325..906f14f3 100644
--- a/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
+++ b/src/main/java/org/fusesource/jansi/internal/JansiLoader.java
@@ -174,43 +174,32 @@ private static boolean extractAndLoadLibraryFile(String libFolderForCurrentOS, S
try {
// Extract a native library file into the target directory
- InputStream in = JansiLoader.class.getResourceAsStream(nativeLibraryFilePath);
- try {
+ try (InputStream in = JansiLoader.class.getResourceAsStream(nativeLibraryFilePath)) {
if (!extractedLckFile.exists()) {
new FileOutputStream(extractedLckFile).close();
}
- OutputStream out = new FileOutputStream(extractedLibFile);
- try {
+ try (OutputStream out = new FileOutputStream(extractedLibFile)) {
copy(in, out);
- } finally {
- out.close();
}
} finally {
// Delete the extracted lib file on JVM exit.
extractedLibFile.deleteOnExit();
extractedLckFile.deleteOnExit();
- in.close();
}
// Set executable (x) flag to enable Java to load the native library
extractedLibFile.setReadable(true);
- extractedLibFile.setWritable(true, true);
+ extractedLibFile.setWritable(true);
extractedLibFile.setExecutable(true);
// Check whether the contents are properly copied from the resource folder
- InputStream nativeIn = JansiLoader.class.getResourceAsStream(nativeLibraryFilePath);
- try {
- InputStream extractedLibIn = new FileInputStream(extractedLibFile);
- try {
+ try (InputStream nativeIn = JansiLoader.class.getResourceAsStream(nativeLibraryFilePath)) {
+ try (InputStream extractedLibIn = new FileInputStream(extractedLibFile)) {
String eq = contentsEquals(nativeIn, extractedLibIn);
if (eq != null) {
throw new RuntimeException(String.format("Failed to write a native library file at %s because %s", extractedLibFile, eq));
}
- } finally {
- extractedLibIn.close();
}
- } finally {
- nativeIn.close();
}
// Load library
@@ -244,7 +233,6 @@ private static void copy(InputStream in, OutputStream out) throws IOException {
*/
private static boolean loadNativeLibrary(File libPath) {
if (libPath.exists()) {
-
try {
String path = libPath.getAbsolutePath();
System.load(path);
@@ -381,7 +369,7 @@ public static String getVersion() {
Properties versionData = new Properties();
versionData.load(versionFile.openStream());
version = versionData.getProperty("version", version);
- version = version.trim().replaceAll("[^0-9\\.]", "");
+ version = version.trim().replaceAll("[^0-9.]", "");
}
} catch (IOException e) {
System.err.println(e);