This is a function for advanced programmers to open a Java InputStream. It's useful if you want to use the facilities provided by PApplet to easily open files from the data folder or from a URL, but want an InputStream object so that you can use other parts of Java to take more control of how the st
(String filename)
| 6321 | * |
| 6322 | */ |
| 6323 | @SuppressWarnings("JavadocLinkAsPlainText") |
| 6324 | public InputStream createInput(String filename) { |
| 6325 | InputStream input = createInputRaw(filename); |
| 6326 | if (input != null) { |
| 6327 | // if it's gzip-encoded, automatically decode |
| 6328 | final String lower = filename.toLowerCase(); |
| 6329 | if (lower.endsWith(".gz") || lower.endsWith(".svgz")) { |
| 6330 | try { |
| 6331 | // buffered has to go *around* the GZ, otherwise 25x slower |
| 6332 | return new BufferedInputStream(new GZIPInputStream(input)); |
| 6333 | |
| 6334 | } catch (IOException e) { |
| 6335 | printStackTrace(e); |
| 6336 | } |
| 6337 | } else { |
| 6338 | return new BufferedInputStream(input); |
| 6339 | } |
| 6340 | } |
| 6341 | return null; |
| 6342 | } |
| 6343 | |
| 6344 | |
| 6345 | /** |
no test coverage detected