1.1 --- a/rt/emul/mini/src/main/java/java/net/URL.java Fri Oct 18 12:29:14 2013 +0200
1.2 +++ b/rt/emul/mini/src/main/java/java/net/URL.java Thu Oct 31 11:23:54 2013 +0100
1.3 @@ -965,9 +965,9 @@
1.4 * @see java.net.URL#URL(java.lang.String, java.lang.String,
1.5 * int, java.lang.String)
1.6 */
1.7 -// public URLConnection openConnection() throws java.io.IOException {
1.8 -// return handler.openConnection(this);
1.9 -// }
1.10 + public URLConnection openConnection() throws java.io.IOException {
1.11 + return handler.openConnection(this);
1.12 + }
1.13
1.14
1.15 /**
1.16 @@ -1058,8 +1058,39 @@
1.17 return null;
1.18 }
1.19
1.20 - static URLStreamHandler getURLStreamHandler(String protocol) {
1.21 - URLStreamHandler universal = new URLStreamHandler() {};
1.22 + static URLStreamHandler getURLStreamHandler(final String protocol) {
1.23 + URLStreamHandler universal = new URLStreamHandler() {
1.24 + @Override
1.25 + protected URLConnection openConnection(URL u) throws IOException {
1.26 + return new URLConnection(u) {
1.27 + Object stream = url.is;
1.28 +
1.29 + @Override
1.30 + public void connect() throws IOException {
1.31 + if (stream == null) {
1.32 + try {
1.33 + byte[] arr = (byte[]) url.getContent(new Class[]{byte[].class});
1.34 + stream = new ByteArrayInputStream(arr);
1.35 + } catch (IOException ex) {
1.36 + stream = ex;
1.37 + throw ex;
1.38 + }
1.39 + }
1.40 + }
1.41 +
1.42 + @Override
1.43 + public InputStream getInputStream() throws IOException {
1.44 + connect();
1.45 + if (stream instanceof IOException) {
1.46 + throw (IOException)stream;
1.47 + }
1.48 + return (InputStream)stream;
1.49 + }
1.50 +
1.51 +
1.52 + };
1.53 + }
1.54 + };
1.55 return universal;
1.56 }
1.57