/** * Initializes a new OBJ Object with the given filename. */ public PShapeOBJ(PApplet parent, String filename) { this(parent, parent.createReader(filename)); }
/** * Shouldn't be part of main p5 reference, this is for advanced users. * Note that while it doesn't accept anything but UTF-8, this is preserved * so that we have some chance of implementing that in the future. * * @nowebref */ public XML(InputStream input, String options) throws IOException, ParserConfigurationException, SAXException { this(PApplet.createReader(input), options); }
/** * Advanced users only; use loadXML() in PApplet. * * @nowebref */ public XML(File file, String options) throws IOException, ParserConfigurationException, SAXException { this(PApplet.createReader(file), options); }
/** * Advanced users only; see loadXML() in PApplet. * * @nowebref */ public XML(File file, String options) throws IOException, ParserConfigurationException, SAXException { this(PApplet.createReader(file), options); }
/** * @nowebref */ static public BufferedReader createReader(File file) { try { InputStream is = new FileInputStream(file); if (file.getName().toLowerCase().endsWith(".gz")) { is = new GZIPInputStream(is); } return createReader(is); } catch (IOException e) { // Re-wrap rather than forcing novices to learn about exceptions throw new RuntimeException(e); } }
/** * @nowebref */ static public JSONObject loadJSONObject(File file) { return new JSONObject(createReader(file)); }
/** * Initializes a new OBJ Object with the given filename. */ public PShapeOBJ(PApplet parent, String filename) { this(parent, parent.createReader(filename), getBasePath(parent, filename)); }
/** * @webref input:files * @param filename name of a file in the data folder or a URL * @see JSONArray * @see PApplet#loadJSONObject(String) * @see PApplet#saveJSONObject(JSONObject, String) * @see PApplet#saveJSONArray(JSONArray, String) */ public JSONArray loadJSONArray(String filename) { return new JSONArray(createReader(filename)); }
static public JSONArray loadJSONArray(File file) { return new JSONArray(createReader(file)); }
/** * @webref input:files * @param filename name of a file in the data folder or a URL * @see JSONObject * @see JSONArray * @see PApplet#loadJSONArray(String) * @see PApplet#saveJSONObject(JSONObject, String) * @see PApplet#saveJSONArray(JSONArray, String) */ public JSONObject loadJSONObject(String filename) { return new JSONObject(createReader(filename)); }
/** * @webref input:files * @param filename name of a file in the data folder or a URL * @see JSONObject * @see JSONArray * @see PApplet#loadJSONArray(String) * @see PApplet#saveJSONObject(JSONObject, String) * @see PApplet#saveJSONArray(JSONArray, String) */ public JSONObject loadJSONObject(String filename) { return new JSONObject(createReader(filename)); }
/** * @webref input:files * @param filename name of a file in the data folder or a URL * @see JSONArray * @see PApplet#loadJSONObject(String) * @see PApplet#saveJSONObject(JSONObject, String) * @see PApplet#saveJSONArray(JSONArray, String) */ public JSONArray loadJSONArray(String filename) { return new JSONArray(createReader(filename)); }
static public JSONObject loadJSONObject(File file) { return new JSONObject(createReader(file)); }
static public JSONArray loadJSONArray(File file) { return new JSONArray(createReader(file)); }
/** * @nowebref */ public XML loadXML(String filename, String options) { try { return new XML(createReader(filename), options); // can't use catch-all exception, since it might catch the // RuntimeException about the incorrect case sensitivity } catch (IOException e) { throw new RuntimeException(e); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } catch (SAXException e) { throw new RuntimeException(e); } }
/** * I want to read lines from a file. And I'm still annoyed. */ static public BufferedReader createReader(File file) { try { InputStream is = new FileInputStream(file); if (file.getName().toLowerCase().endsWith(".gz")) { is = new GZIPInputStream(is); } return createReader(is); } catch (Exception e) { if (file == null) { throw new RuntimeException("File passed to createReader() was null"); } else { e.printStackTrace(); throw new RuntimeException("Couldn't create a reader for " + file.getAbsolutePath()); } } //return null; }
/** * I want to read lines from a file. I have RSI from typing these * eight lines of code so many times. */ public BufferedReader createReader(String filename) { try { InputStream is = createInput(filename); if (is == null) { System.err.println(filename + " does not exist or could not be read"); return null; } return createReader(is); } catch (Exception e) { if (filename == null) { System.err.println("Filename passed to reader() was null"); } else { System.err.println("Couldn't create a reader for " + filename); } } return null; }
/** * ( begin auto-generated from createReader.xml ) * * Creates a <b>BufferedReader</b> object that can be used to read files * line-by-line as individual <b>String</b> objects. This is the complement * to the <b>createWriter()</b> function. * <br/> <br/> * Starting with Processing release 0134, all files loaded and saved by the * Processing API use UTF-8 encoding. In previous releases, the default * encoding for your platform was used, which causes problems when files * are moved to other platforms. * * ( end auto-generated ) * @webref input:files * @param filename name of the file to be opened * @see BufferedReader * @see PApplet#createWriter(String) * @see PrintWriter */ public BufferedReader createReader(String filename) { InputStream is = createInput(filename); if (is == null) { System.err.println("The file \"" + filename + "\" " + "is missing or inaccessible, make sure " + "the URL is valid or that the file has been " + "added to your sketch and is readable."); return null; } return createReader(is); }
int result = -1; try { BufferedReader out = createReader(p.getInputStream()); BufferedReader err = createReader(p.getErrorStream()); result = p.waitFor(); String line;
BufferedReader reader = PApplet.createReader(input); if (awfulCSV) { parseAwfulCSV(reader, header);