MCPcopy Index your code
hub / github.com/processing/processing / createInputRaw

Method createInputRaw

core/src/processing/core/PApplet.java:7128–7282  ·  view source on GitHub ↗

Call openStream() without automatic gzip decompression.

(String filename)

Source from the content-addressed store, hash-verified

7126 * Call openStream() without automatic gzip decompression.
7127 */
7128 public InputStream createInputRaw(String filename) {
7129 if (filename == null) return null;
7130
7131 if (sketchPath == null) {
7132 System.err.println("The sketch path is not set.");
7133 throw new RuntimeException("Files must be loaded inside setup() or after it has been called.");
7134 }
7135
7136 if (filename.length() == 0) {
7137 // an error will be called by the parent function
7138 //System.err.println("The filename passed to openStream() was empty.");
7139 return null;
7140 }
7141
7142 // First check whether this looks like a URL
7143 if (filename.contains(":")) { // at least smells like URL
7144 try {
7145 URL url = new URL(filename);
7146 URLConnection conn = url.openConnection();
7147
7148 if (conn instanceof HttpURLConnection) {
7149 HttpURLConnection httpConn = (HttpURLConnection) conn;
7150 // Will not handle a protocol change (see below)
7151 httpConn.setInstanceFollowRedirects(true);
7152 int response = httpConn.getResponseCode();
7153 // Default won't follow HTTP -> HTTPS redirects for security reasons
7154 // http://stackoverflow.com/a/1884427
7155 if (response >= 300 && response < 400) {
7156 String newLocation = httpConn.getHeaderField("Location");
7157 return createInputRaw(newLocation);
7158 }
7159 return conn.getInputStream();
7160 } else if (conn instanceof JarURLConnection) {
7161 return url.openStream();
7162 }
7163 } catch (MalformedURLException mfue) {
7164 // not a url, that's fine
7165
7166 } catch (FileNotFoundException fnfe) {
7167 // Added in 0119 b/c Java 1.5 throws FNFE when URL not available.
7168 // http://dev.processing.org/bugs/show_bug.cgi?id=403
7169
7170 } catch (IOException e) {
7171 // changed for 0117, shouldn't be throwing exception
7172 printStackTrace(e);
7173 //System.err.println("Error downloading from URL " + filename);
7174 return null;
7175 //throw new RuntimeException("Error downloading from URL " + filename);
7176 }
7177 }
7178
7179 InputStream stream = null;
7180
7181 // Moved this earlier than the getResourceAsStream() checks, because
7182 // calling getResourceAsStream() on a directory lists its contents.
7183 // http://dev.processing.org/bugs/show_bug.cgi?id=716
7184 try {
7185 // First see if it's in a data folder. This may fail by throwing

Callers 2

createInputMethod · 0.95
saveStreamMethod · 0.95

Calls 9

printStackTraceMethod · 0.95
dataPathMethod · 0.95
sketchFileMethod · 0.95
sketchPathMethod · 0.95
getClassLoaderMethod · 0.80
printlnMethod · 0.45
containsMethod · 0.45
getNameMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected