List of usage examples for java.io BufferedWriter newLine
public void newLine() throws IOException
From source file:hu.sztaki.lpds.submitter.service.jobstatus.JobStatusServlet.java
/** Write log into sys.log & stdout. *//* www . jav a 2s .c o m*/ private void sysLog(String jobID, String txt) { try { if (Conf.getP().getDebug() > 0) { // System.out.println(" JSS " + txt); if (!"".equals(jobID)) { File logfile = new File(Base.getI().getPath() + jobID + "/outputs/plugin.log"); if (logfile.exists()) { FileWriter tmp = new FileWriter(logfile, true); BufferedWriter out = new BufferedWriter(tmp); out.newLine(); out.write(" JSS " + txt); out.flush(); out.close(); } } } } catch (Exception e) { //e.printStackTrace(); } }
From source file:apriori.ItemSet.java
public void print(BufferedWriter output) throws IOException { String s = "Item: " + _sortedItems.toString() + ", Support: " + _support.toString(); output.write(s);/* ww w .j av a2 s.c o m*/ output.newLine(); }
From source file:com.imaginary.home.controller.RelayTest.java
@Before public void setUp() throws IOException { File f = new File("target/iha"); if (!f.exists()) { //noinspection ResultOfMethodCallIgnored f.mkdir();/*from www .j a va2 s .co m*/ } f = new File(HomeController.CONFIG_FILE); if (!f.exists()) { HashMap<String, Object> cfg = new HashMap<String, Object>(); cfg.put("name", "Relay Test"); ArrayList<Map<String, Object>> systems = new ArrayList<Map<String, Object>>(); HashMap<String, Object> hue = new HashMap<String, Object>(); HashMap<String, Object> auth = new HashMap<String, Object>(); String hueIp = System.getProperty("ip"); String hueAccessKey = System.getProperty("accessKey"); auth.put("ipAddress", hueIp); auth.put("accessKey", hueAccessKey); hue.put("cname", Hue.class.getName()); hue.put("id", "1"); hue.put("authenticationProperties", auth); hue.put("customProperties", new HashMap<String, Object>()); systems.add(hue); cfg.put("systems", systems); cfg.put("services", new ArrayList<Map<String, Object>>()); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f))); writer.write((new JSONObject(cfg)).toString()); writer.newLine(); writer.flush(); writer.close(); } }
From source file:com.github.jmabuin.blaspark.io.IO.java
public static void writeMatrixToFileInHDFS(String file, DistributedMatrix matrix, Configuration conf) { try {/* ww w. j av a 2 s . co m*/ List<IndexedRow> localRows; long numRows = 0; long numCols = 0; FileSystem fs = FileSystem.get(conf); Path pt = new Path(file); //FileSystem fileSystem = FileSystem.get(context.getConfiguration()); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fs.create(pt, true))); JavaRDD<IndexedRow> rows; if (matrix.getClass() == IndexedRowMatrix.class) { rows = ((IndexedRowMatrix) matrix).rows().toJavaRDD(); } else if (matrix.getClass() == CoordinateMatrix.class) { rows = ((CoordinateMatrix) matrix).toIndexedRowMatrix().rows().toJavaRDD(); } else if (matrix.getClass() == BlockMatrix.class) { rows = ((BlockMatrix) matrix).toIndexedRowMatrix().rows().toJavaRDD(); } else { rows = null; } localRows = rows.collect(); Vector vectors[] = new Vector[localRows.size()]; for (int i = 0; i < localRows.size(); i++) { vectors[(int) localRows.get(i).index()] = localRows.get(i).vector(); } numRows = matrix.numRows(); numCols = matrix.numCols(); bw.write("%%MatrixMarket matrix array real general"); bw.newLine(); bw.write(numRows + " " + numCols + " " + (numRows * numCols)); bw.newLine(); for (int i = 0; i < vectors.length; i++) { bw.write(i + ":"); for (int j = 0; j < vectors[i].size(); j++) { bw.write(String.valueOf(vectors[i].apply(j)) + ","); } bw.newLine(); } bw.close(); //fs.close(); } catch (IOException e) { LOG.error("Error in " + IO.class.getName() + ": " + e.getMessage()); e.printStackTrace(); System.exit(1); } }
From source file:org.envirocar.tools.TrackToCSV.java
public InputStream convert(InputStream in) throws IOException { FeatureCollection fc = new ObjectMapper().readValue(in, FeatureCollection.class); List<String> properties = new ArrayList<String>(); for (Feature feature : fc.getFeatures()) { for (String key : feature.getProperties().getPhenomenons().keySet()) { if (!properties.contains(key)) { properties.add(key);/*from www . j av a2 s . com*/ } } } List<String> spaceTimeProperties = new ArrayList<String>(); spaceTimeProperties.add("longitude"); spaceTimeProperties.add("latitude"); spaceTimeProperties.add("time"); ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(out)); bw.append(createCSVHeader(properties, spaceTimeProperties)); bw.newLine(); for (Feature feature : fc.getFeatures()) { for (int i = 0; i < properties.size(); i++) { String key = properties.get(i); Map<?, ?> value = (Map<?, ?>) feature.getProperties().getPhenomenons().get(key); bw.append(value != null ? value.get("value").toString() : Double.toString(Double.NaN)); bw.append(delimiter); } Point coord = (Point) feature.getGeometry(); bw.append(Double.toString(coord.getCoordinates().getLongitude())); bw.append(delimiter); bw.append(Double.toString(coord.getCoordinates().getLatitude())); bw.append(delimiter); bw.append(feature.getProperties().getTime()); bw.newLine(); } bw.flush(); bw.close(); return new ByteArrayInputStream(out.toByteArray()); }
From source file:br.bireme.ngrams.NGrams.java
private static void writeOutput(final Parameters parameters, final Set<Result> results, final BufferedWriter writer) throws IOException { assert parameters != null; assert results != null; assert writer != null; boolean first = true; writer.newLine(); for (String pipe : results2pipe(parameters, results)) { if (first) { first = false;//from w w w . j a va 2s .com } else { writer.newLine(); } writer.append(pipe); } }
From source file:m3umaker.exFiles.java
public void genFile(String Path, String M3UfileName, List Files) { try {/*from www. ja v a2 s. c o m*/ BufferedWriter out = new BufferedWriter(new FileWriter(Path + "\\" + M3UfileName + ".m3u", true)); for (int i = 0; i < Files.size(); i++) { out.write(Files.get(i).toString()); out.newLine(); } out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.sciaps.utils.ImportExportSpectrumCSV.java
public void exportSpectrumFile(File saveFile, RawDataSpectrum spectrum) throws IOException { if (spectrum == null || saveFile == null) { logger_.warn("", "will not save spectrum csv file"); return;//from w w w. ja va2s . c o m } BufferedWriter bout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(saveFile))); try { bout.append("wavelength, intensity"); bout.newLine(); double[][] data = spectrum.getRawData(); for (int i = 0; i < data[0].length; i++) { bout.append(Double.toString(data[0][i])); bout.append(", "); bout.append(Double.toString(data[1][i])); bout.newLine(); } } finally { bout.close(); } logger_.info("saved spectrum csv file to " + saveFile.getAbsolutePath()); }
From source file:de.electricdynamite.pasty.GCMIntentService.java
private void cacheClipboard(JSONArray clipboard) { File mDeviceCacheFile = new File(this.getCacheDir(), CACHEFILE); try {/* w ww. j a va 2 s .c o m*/ mDeviceCacheFile.createNewFile(); FileWriter fw = new FileWriter(mDeviceCacheFile); BufferedWriter bw = new BufferedWriter(fw); bw.write(clipboard.toString()); bw.newLine(); bw.close(); if (LOCAL_LOG) Log.v(TAG, "cacheClipboard(): Saved result to cache"); } catch (IOException e) { Log.w(TAG, "cacheClipboard(): Could not create cache file"); } }
From source file:com.anton.gavel.ComplaintSubmission.java
public void appendLog(String text) { File logFile = new File("sdcard/log.txt"); if (logFile.exists()) logFile.delete();/*from w w w. j a va 2s .co m*/ if (!logFile.exists()) { try { logFile.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { //BufferedWriter for performance, true to set append to file flag BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true)); buf.append(text); buf.newLine(); buf.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }