List of usage examples for java.io PrintWriter flush
public void flush()
From source file:eu.project.ttc.tools.cli.TermSuiteCLIUtils.java
/** * Prints the command line usage to the std error output * //from w w w. ja va2 s. c o m * @param e * The error that raised the help message * @param cmdLine * The command line usage * @param options * The options expected */ public static void printUsage(ParseException e, String cmdLine, Options options) { System.err.println(e.getMessage()); // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(System.err); formatter.printUsage(pw, cmdLine.length() + 7, cmdLine, options); pw.flush(); }
From source file:com.indivica.olis.Driver.java
static void writeToFile(String data) { try {// ww w . ja v a 2 s . c om File tempFile = new File(System.getProperty("java.io.tmpdir") + (Math.random() * 100) + ".xml"); PrintWriter pw = new PrintWriter(new FileWriter(tempFile)); pw.println(data); pw.flush(); pw.close(); } catch (Exception e) { MiscUtils.getLogger().error("Error", e); } }
From source file:Main.java
public static void writeXML(Document d, OutputStream os, String sysID) throws IOException { /**/*from w w w . java 2 s. co m*/ * To support i18n, we have to specify the encoding of * output writer to UTF-8 when we writing the XML. */ // PrintWriter out=new PrintWriter(os); PrintWriter out = new PrintWriter(new OutputStreamWriter(os, "UTF-8")); out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); out.println(); if (sysID != null) { out.println("<!DOCTYPE " + d.getDoctype().getName() + " SYSTEM \"" + sysID + "\">"); out.println(); } //d.getDocumentElement().normalize(); writeXMLwalkTree(d.getDocumentElement(), 0, out); out.flush(); }
From source file:edu.samplu.common.ITUtil.java
/** * Write the given stack trace into a String remove the ats in an attempt to not cause Jenkins problems. * @param throwable whose stack trace to return * @return String of the given throwable's stack trace. *//*from w w w . j a va 2 s . c o m*/ public static String stackTrace(Throwable throwable) { StringWriter wrt = new StringWriter(); PrintWriter pw = new PrintWriter(wrt); throwable.printStackTrace(pw); pw.flush(); return wrt.toString().replace(" at ", ""); }
From source file:com.sec.ose.osi.util.tools.FileOperator.java
public static boolean saveFile(String filePath, String contents) { File writeFile = new File(filePath); PrintWriter writer = null; try {/*ww w. ja v a 2 s. com*/ writer = new PrintWriter(new FileWriter(writeFile)); writer.println(contents); } catch (IOException e) { // TODO Auto-generated catch block log.warn(e); return false; } finally { if (writer != null) { writer.flush(); writer.close(); } writer = null; } return true; }
From source file:com.barclays.dfe.fw.DFEWatcher.java
/** * Prints the usage./* w ww . ja va 2 s . c o m*/ * * @param applicationName the application name * @param options the options * @param out the out */ public static void printUsage(final String applicationName, final Options options, final OutputStream out) { final PrintWriter writer = new PrintWriter(out); final HelpFormatter usageFormatter = new HelpFormatter(); usageFormatter.printUsage(writer, 80, applicationName, options); writer.flush(); }
From source file:io.apiman.tools.i18n.TemplateScanner.java
/** * Output the sorted map of strings to the specified output file. * @param strings//w w w . j a va 2 s . co m * @param outputFile * @throws FileNotFoundException */ private static void outputMessages(TreeMap<String, String> strings, File outputFile) throws FileNotFoundException { PrintWriter writer = new PrintWriter(new FileOutputStream(outputFile)); for (Entry<String, String> entry : strings.entrySet()) { String key = entry.getKey(); String val = entry.getValue(); writer.append(key); writer.append('='); writer.append(val); writer.append("\n"); } writer.flush(); writer.close(); }
From source file:com.sunchenbin.store.feilong.servlet.http.ResponseUtil.java
/** * .//from www. j a v a 2 s .c o m * * @param response * HttpServletResponse * @param content * * @param contentType * the content type * @param characterEncoding * the character encoding * @see javax.servlet.ServletResponse#getWriter() * @see java.io.PrintWriter#print(Object) * @see java.io.PrintWriter#flush() * @since 1.0.9 */ public static void write(HttpServletResponse response, Object content, String contentType, String characterEncoding) { try { //? ? getWriter? if (Validator.isNotNullOrEmpty(contentType)) { response.setContentType(contentType); } if (Validator.isNotNullOrEmpty(characterEncoding)) { response.setCharacterEncoding(characterEncoding); } PrintWriter printWriter = response.getWriter(); printWriter.print(content); printWriter.flush(); //http://www.iteye.com/problems/56543 //tomcatjetty?? printWriter.close(); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:mx.unam.ecologia.gye.coalescence.app.CreateMicsatInput.java
protected static final void writeMicsat(List leaves, String fname) { try {/* w w w. ja v a 2s. c om*/ FileOutputStream fout = new FileOutputStream(fname); PrintWriter pw = new PrintWriter(fout); for (int i = 0; i < leaves.size(); i++) { UniParentalGene upgene = (UniParentalGene) leaves.get(i); CompoundSequence h = upgene.getCompoundSequence(); int numloc = h.getSequenceCount(); for (int n = 0; n < numloc; n++) { Sequence s = h.get(n); pw.print(s.getSize()); pw.print(" "); } pw.println(); } pw.flush(); pw.close(); fout.close(); } catch (IOException ex) { log.error("writeMicsat()", ex); } }
From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java
static void printRuleDocEnd(PrintWriter out) throws Exception { out.println(" </body>"); out.println("</document>"); out.println();//from ww w . j av a 2s .c o m out.flush(); out.close(); }