1 /*******************************************************************************
2 * Copyright (c) 2008, 2009 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Ferenc Hechler - initial API and implementation
10 * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 219530 [jar application] add Jar-in-Jar ClassLoader option
11 * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262746 [jar exporter] Create a builder for jar-in-jar-loader.zip
12 * Ferenc Hechler, ferenc_hechler@users.sourceforge.net - 262748 [jar exporter] extract constants for string literals in JarRsrcLoader et al.
13 *******************************************************************************/
14 package org.eclipse.jdt.internal.jarinjarloader;
16 import java.io.IOException;
17 import java.io.InputStream;
18 import java.net.MalformedURLException;
20 import java.net.URLConnection;
21 import java.net.URLDecoder;
25 * This class will be compiled into the binary jar-in-jar-loader.zip. This ZIP is used for the
26 * "Runnable JAR File Exporter"
30 public class RsrcURLConnection extends URLConnection {
32 private ClassLoader classLoader;
34 public RsrcURLConnection(URL url, ClassLoader classLoader) {
36 this.classLoader= classLoader;
39 public void connect() throws IOException {
42 public InputStream getInputStream() throws IOException {
43 String file= URLDecoder.decode(url.getFile(), JIJConstants.UTF8_ENCODING);
44 InputStream result= classLoader.getResourceAsStream(file);
46 throw new MalformedURLException("Could not open InputStream for URL '" + url + "'"); //$NON-NLS-1$ //$NON-NLS-2$