List of usage examples for java.io Writer write
public void write(String str) throws IOException
From source file:Main.java
public static void writeToWriter(Iterator it, Writer out) throws IOException { while (it.hasNext()) { out.write(it.next().toString()); out.write(newLine);/*from w w w.ja v a2 s.com*/ } out.flush(); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.sampling.XStreamTools.java
public static String toXML(Object object) throws IOException { Writer out = new StringWriter(); out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); XStream xStream = getXStream();// w ww . j a v a 2 s. c om xStream.toXML(object, out); IOUtils.closeQuietly(out); return out.toString(); }
From source file:dualcontrol.DualControlDigest.java
public static byte[] getBytes(char[] chars) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); Writer writer = new OutputStreamWriter(baos); writer.write(chars); writer.close();//ww w . j a v a 2 s . c o m return baos.toByteArray(); }
From source file:Main.java
/** * Writes the specified number of tabs to the writer. * @param w the output writer.//ww w .j a va2s . c o m * @param nrOfTabs the number of tabs. */ public static void writeTabs(Writer w, int nrOfTabs) throws IOException { for (int i = 0; i < nrOfTabs; ++i) { w.write("\t"); } }
From source file:Main.java
public static void createAccessLog(String accessLog, String fileName) { makeDirectory(getFilesDir());//from w w w .j a v a 2 s . co m FileOutputStream fos = null; try { File newFile = new File(getFilesDir(), fileName); if (!newFile.exists()) { newFile.createNewFile(); } fos = new FileOutputStream(newFile, false); Writer writer = new OutputStreamWriter(fos); writer.write(accessLog); writer.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:StreamConverter.java
static void writeOutput(String str) { try {/*from ww w . jav a2s .c o m*/ FileOutputStream fos = new FileOutputStream("test.txt"); Writer out = new OutputStreamWriter(fos, "UTF8"); out.write(str); out.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:OutputStreamDemo.java
static void writeints(String msg, int count, Writer os) throws IOException { long currentTime = System.currentTimeMillis(); for (int i = 0; i < count; i++) os.write(i & 255); os.close();/*from w w w.j ava 2 s . c o m*/ System.out.println(msg + Long.toString(System.currentTimeMillis() - currentTime)); }
From source file:Main.java
public static InputStream getUTF8Stream(String s) { try {/*from w w w . j a v a2 s .c o m*/ ByteArrayOutputStream bas = new ByteArrayOutputStream(); Writer w = new OutputStreamWriter(bas, "utf-8"); w.write(s); w.close(); byte[] ba = bas.toByteArray(); ByteArrayInputStream bis = new ByteArrayInputStream(ba); return bis; } catch (IOException e) { throw new RuntimeException("should not happen"); } }
From source file:Main.java
public static void writeToWriter(Enumeration enumList, Writer out) throws IOException { while (enumList.hasMoreElements()) { out.write(enumList.nextElement().toString()); out.write(newLine);//from www . j av a 2 s. c om } out.flush(); }
From source file:Main.java
public static void writeXml(String content, String path) { try {//from w ww. j ava 2 s . c o m File file = new File(path); Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "utf-8")); out.write(content); out.flush(); } catch (Exception e) { e.printStackTrace(); } }