/** * @nowebref */ static public void saveStrings(File file, String data[]) { saveStrings(createOutput(file), data); }
static public void saveStrings(File file, String strings[]) { try { String location = file.getAbsolutePath(); createPath(location); OutputStream output = new FileOutputStream(location); if (file.getName().toLowerCase().endsWith(".gz")) { output = new GZIPOutputStream(output); } saveStrings(output, strings); output.close(); } catch (IOException e) { e.printStackTrace(); } }
public void saveStrings(String filename, String strings[]) { saveStrings(saveFile(filename), strings); }
static public void saveFile(String str, File file) throws IOException { File temp = File.createTempFile(file.getName(), null, file.getParentFile()); try { // fix from cjwant to prevent symlinks from being destroyed. File canon = file.getCanonicalFile(); file = canon; } catch(IOException e) { throw new IOException("Could not resolve canonical representation of " + file.getAbsolutePath()); } PApplet.saveStrings(temp, new String[] { str }); if(file.exists()) { boolean result = file.delete(); if (!result) { throw new IOException("Could not remove old version of " + file.getAbsolutePath()); } } boolean result = temp.renameTo(file); if(!result) throw new IOException("Could not replace " + file.getAbsolutePath()); }
void calibrateColors() { // Save the color calibration colorMode(RGB, 255); for (int colorId = 0; colorId < nbColors; colorId++) { ColorReferenceThresholds c = new ColorReferenceThresholds(colorId); int[] colorData = new int[nbScreenPoints * 2]; for (int i = 0; i < nbScreenPoints * 2; i++) { colorData[i] = this.savedColors[i][colorId]; } String[] list = c.createReference(colorData); String saveFile = Papart.colorThresholds + colorId + ".txt"; parent.saveStrings(saveFile, list); if (colorId == 0) { parent.saveStrings(Papart.redThresholds, list); } if (colorId == 1) { parent.saveStrings(Papart.blueThresholds, list); } } }
public void saveToYAML(PApplet parent, String fileName) { assert (isValid()); StringBuilder builder = new StringBuilder("%YAML:1.0\n"); this.addTo(builder); parent.saveStrings(fileName, new String[] {builder.toString()}); }
/** * Save a PMatrix3D to a file. Really simple file format, using saveStrings. * * @param pa * @param mat * @param filename */ public static void savePMatrix3D(PApplet pa, PMatrix3D mat, String filename) { String[] lines = new String[16]; lines[0] = Float.toString(mat.m00); lines[1] = Float.toString(mat.m01); lines[2] = Float.toString(mat.m02); lines[3] = Float.toString(mat.m03); lines[4] = Float.toString(mat.m10); lines[5] = Float.toString(mat.m11); lines[6] = Float.toString(mat.m12); lines[7] = Float.toString(mat.m13); lines[8] = Float.toString(mat.m20); lines[9] = Float.toString(mat.m21); lines[10] = Float.toString(mat.m22); lines[11] = Float.toString(mat.m23); lines[12] = Float.toString(mat.m30); lines[13] = Float.toString(mat.m31); lines[14] = Float.toString(mat.m32); lines[15] = Float.toString(mat.m33); pa.saveStrings(filename, lines); }
/** * ( begin auto-generated from saveStrings.xml ) * * Writes an array of strings to a file, one line per string. This file is * saved to the sketch's folder, which is opened by selecting "Show sketch * folder" from the "Sketch" menu.<br /> * <br /> * It is not possible to use saveXxxxx() functions inside a web browser * unless the sketch is <a * href="http://wiki.processing.org/w/Sign_an_Applet">signed applet</A>. To * save a file back to a server, see the <a * href="http://wiki.processing.org/w/Saving_files_to_a_web-server">save to * web</A> code snippet on the Processing Wiki.<br/> * <br/ > * Starting with Processing 1.0, 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 output:files * @param filename filename for output * @param data string array to be written * @see PApplet#loadStrings(String) * @see PApplet#loadBytes(String) * @see PApplet#saveBytes(String, byte[]) */ public void saveStrings(String filename, String data[]) { saveStrings(saveFile(filename), data); }
PApplet.saveStrings(cfgFile, new String[] {miraFolder.getAbsolutePath()});
PApplet.saveStrings(varFile, varLines); PApplet.saveStrings(pvalFile, pvalLines); PApplet.saveStrings(rangeFile, rangeLines); PApplet.saveStrings(aliasFile, aliasLines); PApplet.saveStrings(unitsFile, unitLines); PApplet.saveStrings(outFile, outLines);