List of usage examples for java.io BufferedWriter BufferedWriter
public BufferedWriter(Writer out)
From source file:com.emc.ecs.sync.filter.IdLoggingFilter.java
@Override public void configure(SyncSource source, Iterator<SyncFilter> filters, SyncTarget target) { try {//from w w w .j a va2 s .co m out = new PrintWriter(new BufferedWriter(new FileWriter(new File(filename)))); } catch (FileNotFoundException e) { throw new ConfigurationException("log file not found", e); } catch (IOException e) { throw new RuntimeException("could not write to log file", e); } }
From source file:edu.umd.cs.findbugs.detect.LpUtil.java
public static void writerLog(Object... str) { BufferedWriter writer = null; try {//from w ww . ja v a 2 s . co m writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(new File("d:\\123000.txt"), true), UTF8.charset)); for (Object temp : str) { writer.write(String.valueOf(temp)); writer.write("\r\n"); } } catch (Exception e) { } finally { try { if (writer != null) { writer.close(); } } catch (IOException e) { } } }
From source file:esiptestbed.mudrod.ontology.pre.AggregateTriples.java
/** * Method of executing triple aggregation */// ww w . j av a2 s . co m @Override public Object execute() { File file = new File(this.props.getProperty("oceanTriples")); if (file.exists()) { file.delete(); } try { file.createNewFile(); } catch (IOException e2) { e2.printStackTrace(); } FileWriter fw; try { fw = new FileWriter(file.getAbsoluteFile()); bw = new BufferedWriter(fw); } catch (IOException e) { e.printStackTrace(); } File[] files = new File(this.props.getProperty("ontologyInputDir")).listFiles(); for (File file_in : files) { String ext = FilenameUtils.getExtension(file_in.getAbsolutePath()); if ("owl".equals(ext)) { try { loadxml(file_in.getAbsolutePath()); getAllClass(); } catch (JDOMException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } } try { bw.close(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:io.druid.storage.google.GoogleTaskLogsTest.java
@Test public void testPushTaskLog() throws Exception { final File tmpDir = Files.createTempDir(); try {//from w w w .java 2s . c o m final File logFile = new File(tmpDir, "log"); BufferedWriter output = new BufferedWriter(new FileWriter(logFile)); output.write("test"); output.close(); storage.insert(EasyMock.eq(bucket), EasyMock.eq(prefix + "/" + taskid), EasyMock.anyObject(InputStreamContent.class)); expectLastCall(); replayAll(); googleTaskLogs.pushTaskLog(taskid, logFile); verifyAll(); } finally { FileUtils.deleteDirectory(tmpDir); } }
From source file:com.coprtools.util.SourceManipulator.java
/** * Writes copyright notice on end of the given file. * * @param file//from w ww. ja v a 2 s.co m * - the given source file * @param notice * - the copyright notice * @throws IOException * - thrown when failed to write a notice to file */ @Override public void writeToFile(File file, String notice) throws IOException { try (Writer writer = new BufferedWriter(new FileWriter(file, true))) { writer.write(notice); } }
From source file:co.rsk.core.NetworkStateExporter.java
public boolean exportStatus(String outputFile) { Repository frozenRepository = this.repository.getSnapshotTo(this.repository.getRoot()); File dumpFile = new File(outputFile); try (FileWriter fw = new FileWriter(dumpFile.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw)) { JsonNodeFactory jsonFactory = new JsonNodeFactory(false); ObjectNode mainNode = jsonFactory.objectNode(); for (ByteArrayWrapper address : frozenRepository.getAccountsKeys()) { if (!address.equals(new ByteArrayWrapper(ZERO_BYTE_ARRAY))) { mainNode.set(Hex.toHexString(address.getData()), createAccountNode(mainNode, address.getData(), frozenRepository)); }/*from w w w. j a v a2 s . com*/ } ObjectMapper mapper = new ObjectMapper(); ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); bw.write(writer.writeValueAsString(mainNode)); return true; } catch (IOException e) { logger.error(e.getMessage(), e); panicProcessor.panic("dumpstate", e.getMessage()); return false; } }
From source file:fr.itinerennes.onebusaway.bundle.tasks.GenerateTripsCsvTask.java
/** * {@inheritDoc}/*from ww w . ja v a 2 s . c o m*/ * * @see java.lang.Runnable#run() */ @Override public void run() { BufferedWriter out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), CHARSET)); // output trips count out.write(String.valueOf(gtfsDao.getAllTrips().size())); out.newLine(); for (final Trip trip : gtfsDao.getAllTrips()) { out.write(trip.getId().toString()); out.write(';'); out.write(trip.getRoute().getId().toString()); out.write(';'); out.write(trip.getTripHeadsign()); out.write(';'); out.write(trip.getDirectionId()); out.write(';'); out.newLine(); } } catch (final FileNotFoundException e) { LOGGER.error("output file not found", e); } catch (final IOException e) { LOGGER.error("can't write to output file", e); } finally { IOUtils.closeQuietly(out); } }
From source file:fr.itinerennes.onebusaway.bundle.tasks.GenerateRoutesCsvTask.java
/** * {@inheritDoc}/*w w w . jav a 2 s .co m*/ * * @see java.lang.Runnable#run() */ @Override public void run() { BufferedWriter out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), CHARSET)); // output routes count out.write(String.valueOf(gtfsDao.getAllRoutes().size())); out.newLine(); for (final Route route : gtfsDao.getAllRoutes()) { out.write(route.getId().toString()); out.write(';'); out.write(route.getShortName()); out.write(';'); out.write(route.getLongName()); out.write(';'); out.write(route.getTextColor()); out.write(';'); out.write(route.getColor()); out.write(';'); out.newLine(); } } catch (final FileNotFoundException e) { LOGGER.error("output file not found", e); } catch (final IOException e) { LOGGER.error("can't write to output file", e); } finally { IOUtils.closeQuietly(out); } }
From source file:JMeterProcessing.JMeterPropertiesGenerator.java
private static void generatePropertiesFile(Map<String, Long> idValuesMap) throws IOException { String propertiesOutputDir = System.getProperty("properties.output.dir"); File original = new File(propertiesOutputDir + "/testray.jmeter.full.depth.properties"); File generated = new File(propertiesOutputDir + "/testray.jmeter.properties"); Files.copy(original.toPath(), generated.toPath(), StandardCopyOption.REPLACE_EXISTING); try (BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(generated, true), "utf-8"))) { printProperties(writer, idValuesMap); writer.flush();//from w w w . j a v a 2 s .c o m } }
From source file:com.thinkit.operationsys.util.FileUtil.java
/** * ?/*from w ww . j ava 2 s . co m*/ * * @param fileName * @param data */ public static void write(String fileName, String data) { BufferedWriter bw = null; try { // String name = getName(link) + "analyze.txt"; bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName))); bw.write(data); bw.flush(); } catch (Exception e) { e.printStackTrace(); } finally { if (null != bw) { try { bw.close(); } catch (IOException e) { e.printStackTrace(); } } } }