List of usage examples for java.io BufferedWriter BufferedWriter
public BufferedWriter(Writer out)
From source file:Main.java
public static void main(String[] args) throws IOException { StringWriter sw = new StringWriter(); BufferedWriter bw = new BufferedWriter(sw); for (int i = 65; i <= 90; i++) { bw.write(i);// w ww . j a va 2 s . c om } bw.flush(); StringBuffer sb = sw.getBuffer(); System.out.println(sb); }
From source file:Main.java
public static void main(String[] args) throws IOException { StringWriter sw = new StringWriter(); BufferedWriter bw = new BufferedWriter(sw); bw.append("java2s.com"); bw.close();/*from w w w . j a v a 2 s. com*/ System.out.println(sw.getBuffer()); // appending after closing will throw error bw.append("2"); System.out.println(sw.getBuffer()); }
From source file:Main.java
public static void main(String args[]) throws Exception { String[] words = { "", "e", "a", "c" }; Writer w = new BufferedWriter(new OutputStreamWriter(System.out, "Cp850")); for (int i = 0; i < 4; i++) { w.write(words[i] + " "); }/*from ww w . j a va2 s.com*/ Arrays.sort(words); for (int i = 0; i < 4; i++) { w.write(words[i] + " "); } w.flush(); w.close(); }
From source file:Main.java
License:asdf
public static void main(String[] argv) throws Exception { File temp = File.createTempFile("pattern", ".dat"); temp.deleteOnExit();/*from w ww. j a va2 s. c o m*/ BufferedWriter out = new BufferedWriter(new FileWriter(temp)); out.write("asdf"); out.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { String str = "from java2s.com!"; StringWriter sw = new StringWriter(); BufferedWriter bw = new BufferedWriter(sw); }
From source file:Main.java
public static void main(String args[]) throws Exception { String[] words = { "", "e", "a", "c" }; Writer w = new BufferedWriter(new OutputStreamWriter(System.out, "Cp850")); for (int i = 0; i < 4; i++) { w.write(words[i] + " "); }//from www . ja v a2 s.c o m sortArray(Collator.getInstance(), words); for (int i = 0; i < 4; i++) { w.write(words[i] + " "); } w.flush(); w.close(); }
From source file:Main.java
public static void main(String[] args) throws IOException { String s = "from java2s.com!"; StringWriter sw = new StringWriter(); BufferedWriter bw = new BufferedWriter(sw); bw.write(s, 0, 5);/*from w ww. ja v a 2 s . com*/ bw.newLine(); bw.write(s, 6, s.length() - 6); bw.flush(); System.out.print(sw.getBuffer()); }
From source file:Main.java
public static void main(String[] args) throws IOException { String letters = "from java2s.com"; StringWriter sw = new StringWriter(); BufferedWriter bw = new BufferedWriter(sw); for (char c : letters.toCharArray()) { bw.append(c);//from w w w. j a v a2 s . c om bw.flush(); System.out.println(sw.getBuffer()); } }
From source file:Main.java
public static void main(String args[]) throws Exception { String s = "<xmltag atr=value>tag data</xmltag>"; FileWriter fr = new FileWriter(new File("a.txt")); Writer br = new BufferedWriter(fr); br.write(s);// w w w.ja va 2 s . co m br.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { BufferedReader br = new BufferedReader(new FileReader("in.txt")); BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); int i;/*from w w w . j av a2s .c om*/ do { i = br.read(); if (i != -1) { if (Character.isLowerCase((char) i)) bw.write(Character.toUpperCase((char) i)); else if (Character.isUpperCase((char) i)) bw.write(Character.toLowerCase((char) i)); else bw.write((char) i); } } while (i != -1); br.close(); bw.close(); }