List of usage examples for java.io BufferedOutputStream BufferedOutputStream
public BufferedOutputStream(OutputStream out)
From source file:Main.java
public static void main(String[] args) throws Exception { BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream("yourFile.txt")); bufferedOutput.write("Line one".getBytes()); bufferedOutput.write("\n".getBytes()); bufferedOutput.write(65);/*from ww w .j a v a 2 s . c om*/ bufferedOutput.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream("output.dat")))); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream("C:/Demo.txt"); BufferedOutputStream bos = new BufferedOutputStream(fos); byte b = 66;/* w ww . java2s. com*/ // write a character represented by ascii 66 i.e. 'B' bos.write(b); bos.flush(); bos.close(); }
From source file:BufferedOutputStreamDemo.java
public static void main(String args[]) throws Exception { FileOutputStream fos = new FileOutputStream(args[0]); BufferedOutputStream bos = new BufferedOutputStream(fos); // Write 12 bytes to the file for (int i = 0; i < 12; i++) { bos.write(i);/*from w w w . ja v a 2 s . c om*/ } bos.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); byte[] bytes = { 1, 2, 3, 4, 5 }; bos.write(bytes, 0, 5);/* w w w .j a va 2 s. c om*/ bos.flush(); for (byte b : baos.toByteArray()) { System.out.print(b); } }
From source file:Main.java
public static void main(String[] args) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedOutputStream bos = new BufferedOutputStream(baos); int b = 87;/* w ww .j a v a2 s . c o m*/ bos.write(b); bos.flush(); byte[] bytes = baos.toByteArray(); System.out.println(bytes[0]); }
From source file:Main.java
public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream(new File("C:/Demo")); BufferedOutputStream bos = new BufferedOutputStream(fos); bos.write("this is a test".getBytes()); bos.flush();// w ww . j av a 2 s . c o m bos.close(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { FileOutputStream fileOut = new FileOutputStream("data.txt"); BufferedOutputStream buffer = new BufferedOutputStream(fileOut); DataOutputStream dataOut = new DataOutputStream(buffer); dataOut.writeUTF("Hello!"); dataOut.writeInt(4);/*from www . j a va 2 s .co m*/ dataOut.writeDouble(100.0); dataOut.close(); buffer.close(); fileOut.close(); }
From source file:MainClass.java
public static void main(String args[]) { try {/* ww w . ja va 2s. com*/ FileOutputStream fos = new FileOutputStream(args[0]); BufferedOutputStream bos = new BufferedOutputStream(fos); for (int i = 0; i < 12; i++) { bos.write(i); } bos.close(); } catch (Exception e) { System.out.println("Exception: " + e); } }
From source file:MainClass.java
public static void main(String[] args) throws IOException { DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(new File("temp.tmp")))); for (int i = 0; i < 10; i++) dos.writeInt(i);//w w w .j av a 2s. co m dos.close(); }