List of usage examples for java.io Writer append
public Writer append(char c) throws IOException
From source file:com.github.rabid_fish.proxy.servlet.SoapServlet.java
void writeWsdl(Writer writer) throws IOException { final String path = "/wsdl/math.wsdl"; File file = FileUtils.toFile(getClass().getResource(path)); String wsdl = FileUtils.readFileToString(file); writer.append(wsdl); }
From source file:org.drools.planner.benchmark.statistic.memoryuse.MemoryUseStatistic.java
private CharSequence writeCsvStatistic(File solverStatisticFilesDirectory, String baseName) { List<MemoryUseScvLine> csvLineList = extractCsvLineList(); File csvStatisticFile = new File(solverStatisticFilesDirectory, baseName + "MemoryUseStatistic.csv"); Writer writer = null; try {/*from w w w .java2 s . c o m*/ writer = new OutputStreamWriter(new FileOutputStream(csvStatisticFile), "utf-8"); writer.append("\"TimeMillisSpend\""); for (String configName : configNameList) { writer.append(",\"").append(configName.replaceAll("\\\"", "\\\"")).append(" used\""); writer.append(",\"").append(configName.replaceAll("\\\"", "\\\"")).append(" max\""); } writer.append("\n"); for (MemoryUseScvLine line : csvLineList) { writer.write(Long.toString(line.getTimeMillisSpend())); for (String configName : configNameList) { writer.append(","); MemoryUseMeasurement memoryUseMeasurement = line.getConfigNameToMemoryUseMeasurementMap() .get(configName); if (memoryUseMeasurement != null) { writer.append(Long.toString(memoryUseMeasurement.getUsedMemory())); writer.append(","); writer.append(Long.toString(memoryUseMeasurement.getMaxMemory())); } } writer.append("\n"); } } catch (IOException e) { throw new IllegalArgumentException("Problem writing csvStatisticFile: " + csvStatisticFile, e); } finally { IOUtils.closeQuietly(writer); } return " <p><a href=\"" + csvStatisticFile.getName() + "\">CVS file</a></p>\n"; }
From source file:com.echosource.ada.rules.AdaProfileExporter.java
private void appendCustomFilters(Writer writer) throws IOException { String filtersXML = conf.getString(AdaPlugin.FILTERS_KEY, AdaPlugin.FILTERS_DEFAULT_VALUE); if (StringUtils.isNotBlank(filtersXML)) { writer.append(filtersXML); }//from w w w.ja va2 s . c om }
From source file:org.optaplanner.benchmark.impl.statistic.SubSingleStatistic.java
private void writeCsvStatisticFile() { File csvFile = getCsvFile();// www. j a v a 2s. com Writer writer = null; try { writer = new OutputStreamWriter(new FileOutputStream(csvFile), "UTF-8"); writer.append(getCsvHeader()).append("\n"); for (StatisticPoint point : getPointList()) { writer.append(point.toCsvLine()).append("\n"); } if (subSingleBenchmarkResult.hasAnyFailure()) { writer.append("Failed\n"); } } catch (IOException e) { throw new IllegalArgumentException("Failed writing csvFile (" + csvFile + ").", e); } finally { IOUtils.closeQuietly(writer); } }
From source file:uniol.apt.compiler.AbstractServiceProcessor.java
/** * Function that writes a resource list into the class output directory. * Existing entries are preserved. This means that this function only ever adds new entries. * @param resourceName Name of the file in which the resource list should be saved. * @param entries Entries that should be added to the list. * @throws IOException In case I/O errors occur. *///w ww. j ava2s . co m protected void writeResourceList(String resourceName, Collection<String> entries) throws IOException { entries = new TreeSet<>(entries); // read already listed services try { FileObject fo = this.filer.getResource(StandardLocation.CLASS_OUTPUT, "", resourceName); try (InputStream is = fo.openInputStream()) { LineIterator lIter = IOUtils.lineIterator(is, "UTF-8"); while (lIter.hasNext()) { String entry = lIter.next(); entries.add(entry); } } } catch (IOException ex) { /* It's ok if the resource can't get found; we only skip reading it */ } // write new list FileObject fo = this.filer.createResource(StandardLocation.CLASS_OUTPUT, "", resourceName); Writer writer = fo.openWriter(); for (String entry : entries) { writer.append(entry + "\n"); } writer.close(); }
From source file:org.drools.planner.benchmark.statistic.BestScoreStatistic.java
private CharSequence writeCsvStatistic(File solverStatisticFilesDirectory, String baseName) { List<TimeToBestScoresLine> timeToBestScoresLineList = extractTimeToBestScoresLineList(); File csvStatisticFile = new File(solverStatisticFilesDirectory, baseName + "Statistic.csv"); Writer writer = null; try {//from w w w . j ava 2s. c o m writer = new OutputStreamWriter(new FileOutputStream(csvStatisticFile), "utf-8"); writer.append("\"TimeMillisSpend\""); for (String configName : configNameList) { writer.append(",\"").append(configName.replaceAll("\\\"", "\\\"")).append("\""); } writer.append("\n"); for (TimeToBestScoresLine timeToBestScoresLine : timeToBestScoresLineList) { writer.write(Long.toString(timeToBestScoresLine.getTimeMillisSpend())); for (String configName : configNameList) { writer.append(","); Score score = timeToBestScoresLine.getConfigNameToScoreMap().get(configName); if (score != null) { Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { writer.append(scoreGraphValue.toString()); } } } writer.append("\n"); } } catch (IOException e) { throw new IllegalArgumentException("Problem writing csvStatisticFile: " + csvStatisticFile, e); } finally { IOUtils.closeQuietly(writer); } return " <p><a href=\"" + csvStatisticFile.getName() + "\">CVS file</a></p>\n"; }
From source file:org.sonatype.nexus.yum.internal.RpmListWriter.java
private void rewriteFileList(Map<String, String> fileMap) throws IOException { Writer writer = new FileWriter(rpmListFile); try {//from ww w.j a v a 2 s. c o m for (Entry<String, String> entry : fileMap.entrySet()) { writer.append(format("%s%s\n", entry.getKey(), entry.getValue())); } } finally { writer.close(); } LOG.debug("Wrote temporary package list to {}", rpmListFile.getAbsoluteFile()); }
From source file:org.drools.planner.benchmark.statistic.bestscore.BestScoreStatistic.java
private CharSequence writeCsvStatistic(File solverStatisticFilesDirectory, String baseName) { List<BestScoreScvLine> scvLineList = extractCsvLineList(); File csvStatisticFile = new File(solverStatisticFilesDirectory, baseName + "BestScoreStatistic.csv"); Writer writer = null; try {//from ww w .j av a2 s . c o m writer = new OutputStreamWriter(new FileOutputStream(csvStatisticFile), "utf-8"); writer.append("\"TimeMillisSpend\""); for (String configName : configNameList) { writer.append(",\"").append(configName.replaceAll("\\\"", "\\\"")).append("\""); } writer.append("\n"); for (BestScoreScvLine line : scvLineList) { writer.write(Long.toString(line.getTimeMillisSpend())); for (String configName : configNameList) { writer.append(","); Score score = line.getConfigNameToScoreMap().get(configName); if (score != null) { Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { writer.append(scoreGraphValue.toString()); } } } writer.append("\n"); } } catch (IOException e) { throw new IllegalArgumentException("Problem writing csvStatisticFile: " + csvStatisticFile, e); } finally { IOUtils.closeQuietly(writer); } return " <p><a href=\"" + csvStatisticFile.getName() + "\">CVS file</a></p>\n"; }
From source file:com.github.rwitzel.streamflyer.experimental.stateful.util.IdleModifierStatePerformanceTest.java
private void assertOverheadByWriter(String input, double expectedMaxSpentTime, double expectedMaxOverhead) throws Exception { // setup: create modifier and writer Writer originalWriter = new StringWriter(); ModifyingWriter writer = new ModifyingWriter(originalWriter, createIdleModifier()); // write the stream to an output stream long start = System.currentTimeMillis(); for (int index = 0; index < input.length(); index++) { writer.append(input.charAt(index)); }/*from w ww .jav a 2s .co m*/ writer.flush(); writer.close(); long end = System.currentTimeMillis(); originalWriter.toString(); Writer writer2 = new StringWriter(); // read the stream into an output stream long start2 = System.currentTimeMillis(); for (int index = 0; index < input.length(); index++) { writer2.append(input.charAt(index)); } writer2.flush(); writer2.close(); long end2 = System.currentTimeMillis(); long overhead = (end - start) - (end2 - start2); assertTime(end - start, expectedMaxSpentTime, "Time spent by ModifyingWriter:"); assertTime(overhead, expectedMaxOverhead, "Overhead by ModifyingWriter:"); }
From source file:org.sonar.plugins.checkstyle.CheckstyleProfileExporter.java
private void appendCustomFilters(Writer writer) throws IOException { String filtersXML = conf.getString(CheckstyleConstants.FILTERS_KEY, CheckstyleConstants.FILTERS_DEFAULT_VALUE); if (StringUtils.isNotBlank(filtersXML)) { writer.append(filtersXML); }/*from w w w . ja va 2s . com*/ }