diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2011-06-10 12:02:13 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2011-06-10 12:02:13 +0000 |
commit | d3ea113a92439aacd69d61445dbfcf8b14e483a3 (patch) | |
tree | 907a6ae691d7387eaa516a14f3ab2393f7d0a93f /src/java/com | |
parent | dc77fd55be1da2ace6744e7066681dce198ebce8 (diff) | |
download | jackcess-d3ea113a92439aacd69d61445dbfcf8b14e483a3.tar.gz jackcess-d3ea113a92439aacd69d61445dbfcf8b14e483a3.zip |
try multiple classloaders when trying to load resources
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@564 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/java/com')
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Database.java | 22 | ||||
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/GeneralLegacyIndexCodes.java | 3 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Database.java b/src/java/com/healthmarketscience/jackcess/Database.java index 96d7aaa..a856b02 100644 --- a/src/java/com/healthmarketscience/jackcess/Database.java +++ b/src/java/com/healthmarketscience/jackcess/Database.java @@ -657,8 +657,7 @@ public class Database FileChannel channel = openChannel(mdbFile, false); channel.truncate(0); - transferFrom(channel, Thread.currentThread().getContextClassLoader() - .getResourceAsStream(fileFormat._emptyFile)); + transferFrom(channel, getResourceAsStream(fileFormat._emptyFile)); return new Database(channel, autoSync, fileFormat, charset, timeZone, null); } @@ -1911,6 +1910,25 @@ public class Database return pwdMask; } + static InputStream getResourceAsStream(String resourceName) + throws IOException + { + InputStream stream = Database.class.getClassLoader() + .getResourceAsStream(resourceName); + + if(stream == null) { + + stream = Thread.currentThread().getContextClassLoader() + .getResourceAsStream(resourceName); + + if(stream == null) { + throw new IOException("Could not load jackcess resource " + + resourceName); + } + } + + return stream; + } /** * Utility class for storing table page number and actual name. diff --git a/src/java/com/healthmarketscience/jackcess/GeneralLegacyIndexCodes.java b/src/java/com/healthmarketscience/jackcess/GeneralLegacyIndexCodes.java index 6206ba2..e6d204c 100644 --- a/src/java/com/healthmarketscience/jackcess/GeneralLegacyIndexCodes.java +++ b/src/java/com/healthmarketscience/jackcess/GeneralLegacyIndexCodes.java @@ -326,8 +326,7 @@ public class GeneralLegacyIndexCodes { reader = new BufferedReader( new InputStreamReader( - Thread.currentThread().getContextClassLoader() - .getResourceAsStream(codesFilePath), "US-ASCII")); + Database.getResourceAsStream(codesFilePath), "US-ASCII")); int start = asUnsignedChar(firstChar); int end = asUnsignedChar(lastChar); |