From d6059c7779427b78e7cf2582308e217c6a320876 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 16 Apr 2005 23:10:25 +0000 Subject: [PATCH] fix for url stuff on openStream --- core/PApplet.java | 24 ++++++++++++------------ core/todo.txt | 4 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/PApplet.java b/core/PApplet.java index 453c791a8..b1ef15b74 100644 --- a/core/PApplet.java +++ b/core/PApplet.java @@ -3033,6 +3033,18 @@ public class PApplet extends Applet public InputStream openStream(String filename) { InputStream stream = null; + try { + URL url = new URL(filename); + stream = url.openStream(); + return stream; + + } catch (MalformedURLException e) { + // not a url, that's fine + + } catch (IOException e) { + throw new RuntimeException("Error downloading from URL " + filename); + } + if (!online) { try { String location = folder + File.separator + "data"; @@ -3063,18 +3075,6 @@ public class PApplet extends Applet } try { - if (filename.startsWith("http://")) { - try { - URL url = new URL(filename); - stream = url.openStream(); - return stream; - - } catch (MalformedURLException e) { - e.printStackTrace(); - return null; - } - } - stream = getClass().getResourceAsStream(filename); if (stream != null) return stream; diff --git a/core/todo.txt b/core/todo.txt index 557c80969..df372652a 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -133,6 +133,10 @@ o make nf/nfs/nfp not so weird o nf(PLUS, ...) nf(PAD, ...) nfc(PLUS, ...) X unhex was broken for numbers bigger than 2^31 +saturday late afternoon +X fix bug with openStream() and upper/lowercase stuff +X do a better job of handling any kind of URLs in openStream() + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .