mirror of
https://github.com/xerial/snappy-java.git
synced 2025-07-25 23:14:34 +02:00
#131: Close version file stream
This commit is contained in:
parent
1198363176
commit
e029c0e560
@ -25,6 +25,7 @@
|
|||||||
package org.xerial.snappy;
|
package org.xerial.snappy;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -282,19 +283,27 @@ public class Snappy
|
|||||||
*/
|
*/
|
||||||
public static String getNativeLibraryVersion()
|
public static String getNativeLibraryVersion()
|
||||||
{
|
{
|
||||||
|
|
||||||
URL versionFile = SnappyLoader.class.getResource("/org/xerial/snappy/VERSION");
|
URL versionFile = SnappyLoader.class.getResource("/org/xerial/snappy/VERSION");
|
||||||
|
|
||||||
String version = "unknown";
|
String version = "unknown";
|
||||||
try {
|
try {
|
||||||
if (versionFile != null) {
|
if (versionFile != null) {
|
||||||
Properties versionData = new Properties();
|
InputStream in = null;
|
||||||
versionData.load(versionFile.openStream());
|
try {
|
||||||
version = versionData.getProperty("version", version);
|
Properties versionData = new Properties();
|
||||||
if (version.equals("unknown")) {
|
in = versionFile.openStream();
|
||||||
version = versionData.getProperty("VERSION", version);
|
versionData.load(in);
|
||||||
|
version = versionData.getProperty("version", version);
|
||||||
|
if (version.equals("unknown")) {
|
||||||
|
version = versionData.getProperty("VERSION", version);
|
||||||
|
}
|
||||||
|
version = version.trim().replaceAll("[^0-9\\.]", "");
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if(in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
version = version.trim().replaceAll("[^0-9\\.]", "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user