List of usage examples for java.io PrintWriter println
public void println(Object x)
From source file:Main.java
/** * Generates the end of an XML tag </fieldName> * * @param fieldName/*from w w w .j ava2 s . co m*/ * @param pw */ static public void writeXMLEnd(String fieldName, PrintWriter pw) { pw.print("</"); pw.print(fieldName); pw.println('>'); }
From source file:Main.java
public static void response(OutputStream output, String contentType, String description, String responseText) { Log.d(">>>NativeH5", " xhr response return start time:" + System.currentTimeMillis() + " responseText:" + responseText); PrintWriter pw = new PrintWriter(output); pw.println("HTTP/1.1 " + description); pw.println("Content-Type: " + contentType); pw.println("Date: " + new Date()); pw.println("Access-Control-Allow-Origin: *"); pw.println("Content-Length: " + responseText.length()); pw.println();//from w w w. j a va 2 s . c o m pw.println(responseText); pw.flush(); try { output.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void writeCopyrightNotice(PrintWriter out, String commentChar) { out.println(" #########################################################################"); out.println(commentChar + " Copyright 2009 DFKI GmbH."); out.println(commentChar + " All Rights Reserved. Use is subject to license terms."); out.println(commentChar);//w w w.j a v a2 s . c om out.println(commentChar + " This file is part of MARY TTS."); out.println(commentChar); out.println(commentChar + " MARY TTS is free software: you can redistribute it and/or modify"); out.println(commentChar + " it under the terms of the GNU Lesser General Public License as published by"); out.println(commentChar + " the Free Software Foundation, version 3 of the License."); out.println(commentChar); out.println(commentChar + " This program is distributed in the hope that it will be useful,"); out.println(commentChar + " but WITHOUT ANY WARRANTY; without even the implied warranty of"); out.println(commentChar + " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"); out.println(commentChar + " GNU Lesser General Public License for more details."); out.println(commentChar); out.println(commentChar + " You should have received a copy of the GNU Lesser General Public License"); out.println(commentChar + " along with this program. If not, see <http://www.gnu.org/licenses/>."); out.println(commentChar); out.println(commentChar + " #########################################################################"); }
From source file:Main.java
public static <K, V> void printMap(Map<K, V> A, File file) throws FileNotFoundException, UnsupportedEncodingException { file.getParentFile().mkdirs();/*from w w w .j av a 2 s . c om*/ PrintWriter p = new PrintWriter(file, "UTF-8"); for (K k : A.keySet()) p.println(k + "\t" + A.get(k)); p.close(); }
From source file:Main.java
public static void outputData(short[] data, PrintWriter writer) { for (int i = 0; i < data.length; i++) { writer.println(String.valueOf(data[i])); }//from w w w .j ava 2 s .co m if (writer.checkError()) { Log.w(TAG, "Error writing sensor event data"); } }
From source file:Main.java
public static void writeToFile(String fileName, String xml) throws IOException { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true), 1024)); out.println(xml); out.flush();//from www . j a va2s. com out.close(); }
From source file:Main.java
public static Boolean writeToSDFile(String directory, String file_name, String text) { // Find the root of the external storage. // See/*from w w w . java 2 s . c o m*/ // http://developer.android.com/guide/topics/data/data-storage.html#filesExternal File root = Environment.getExternalStorageDirectory(); // See // http://stackoverflow.com/questions/3551821/android-write-to-sd-card-folder File dir = new File(root.getAbsolutePath() + "/" + directory); dir.mkdirs(); File file = new File(dir, file_name); try { FileOutputStream f = new FileOutputStream(file); PrintWriter pw = new PrintWriter(f); pw.println(text); pw.flush(); pw.close(); f.close(); // Log.v(TAG, "file written to sd card"); return true; } catch (FileNotFoundException e) { e.printStackTrace(); // Log.i(TAG, "******* File not found. Did you" + // " add a WRITE_EXTERNAL_STORAGE permission to the manifest?"); return false; } catch (IOException e) { e.printStackTrace(); return false; } }
From source file:com.alibaba.wasp.util.VersionInfo.java
public static void writeTo(PrintWriter out) { for (String line : versionReport()) { out.println(line); }//ww w. j ava 2s.c om }
From source file:eu.delving.services.controller.ServiceController.java
private static void report(HttpServletResponse response, String message) throws IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html><head><title>Resolver</title></head><body><h2>"); out.println(message);/*from w w w . ja va2 s .co m*/ out.println("</body></html></h2>"); }
From source file:edu.usf.cutr.obascs.io.FileUtil.java
public static void writeToFile(String text, String path) throws FileNotFoundException { File file = new File(path); PrintWriter printWriter = new PrintWriter(file); printWriter.println(text); printWriter.close();// ww w . j a v a 2s .c o m }