fix for url stuff on openStream

This commit is contained in:
benfry
2005-04-16 23:10:25 +00:00
parent 6f8eb9b09f
commit d6059c7779
2 changed files with 16 additions and 12 deletions
+12 -12
View File
@@ -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;
+4
View File
@@ -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()
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .