diff options
Diffstat (limited to 'utils/src/main/java/at/gv/egiz/bku/utils/ClasspathURLStreamHandler.java')
-rw-r--r-- | utils/src/main/java/at/gv/egiz/bku/utils/ClasspathURLStreamHandler.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/utils/src/main/java/at/gv/egiz/bku/utils/ClasspathURLStreamHandler.java b/utils/src/main/java/at/gv/egiz/bku/utils/ClasspathURLStreamHandler.java new file mode 100644 index 00000000..1cd46fb5 --- /dev/null +++ b/utils/src/main/java/at/gv/egiz/bku/utils/ClasspathURLStreamHandler.java @@ -0,0 +1,34 @@ +/* +* Copyright 2009 Federal Chancellery Austria and +* Graz University of Technology +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package at.gv.egiz.bku.utils; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +public class ClasspathURLStreamHandler extends URLStreamHandler { + + @Override + protected URLConnection openConnection(URL u) throws IOException { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + URL resource = classLoader.getResource(u.getPath()); + return resource.openConnection(); + } + +} |