Example usage for java.io BufferedOutputStream BufferedOutputStream

List of usage examples for java.io BufferedOutputStream BufferedOutputStream

Introduction

In this page you can find the example usage for java.io BufferedOutputStream BufferedOutputStream.

Prototype

public BufferedOutputStream(OutputStream out) 

Source Link

Document

Creates a new buffered output stream to write data to the specified underlying output stream.

Usage

From source file:Main.java

public static void main(String[] arguments) {
    try {/*from  w  w w  .j a v  a  2  s  .c  om*/
        FileOutputStream file = new FileOutputStream("p.dat");
        BufferedOutputStream buff = new BufferedOutputStream(file);
        DataOutputStream data = new DataOutputStream(buff);

        for (int i = 0; i < 400; i++)
            data.writeInt(i);
        data.close();
    } catch (IOException e) {
        System.out.println("Error - " + e.toString());
    }
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    MyClass o = new MyClass(123);

    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("outfilename.xml")));

    String[] propertyNames = new String[] { "prop" };
    encoder.setPersistenceDelegate(MyClass.class, new DefaultPersistenceDelegate(propertyNames));

    encoder.writeObject(o);//  w w  w  .  j  a v a  2 s.co m
    encoder.close();

}

From source file:Main.java

public static void main(String[] atgs) throws Exception {
    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("java.txt")));
    out.writeUTF("");
    out.writeBytes("a");
    out.writeChars("aaa");
    out.close();/*from   w  ww  .  ja  v  a  2  s.  c  om*/
    DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("java.txt")));
    System.out.println(in.readUTF());
    byte[] buf = new byte[1024];
    int len = in.read(buf);
    System.out.println(new String(buf, 0, len));
    in.close();
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    MyClass o = new MyClass();
    o.setProp(1);/*ww  w. j av a2s.  c o m*/
    o.setProps(new int[] { 1, 2, 3 });

    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("outfilename.xml")));
    encoder.writeObject(o);
    encoder.close();

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    BufferedInputStream fin = new BufferedInputStream(new FileInputStream("in.dat"));
    BufferedOutputStream fout = new BufferedOutputStream(new FileOutputStream("out.dat"));
    int i;/*from ww w . j  a  v  a2s  .  c o  m*/
    do {
        i = fin.read();
        if (i != -1)
            fout.write(i);
    } while (i != -1);
    fin.close();
    fout.close();
}

From source file:MainClass.java

public static void main(String[] args) throws IOException {
    DataOutputStream out2 = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("Data.txt")));
    out2.writeDouble(3.14159);// w w  w . j  a v  a 2s .  c  o m
    out2.writeUTF("Square root of 2");
    out2.close();

    DataInputStream in5 = new DataInputStream(new BufferedInputStream(new FileInputStream("Data.txt")));

    System.out.println(in5.readDouble());
    System.out.println(in5.readUTF());
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    FileInputStream is = new FileInputStream("c:/test.txt");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BufferedOutputStream bos = new BufferedOutputStream(baos);

}

From source file:Main.java

public static void main(String[] args) throws Exception {

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.write("java2s.com".getBytes(), 1, 2);
    out.close();//from   w w  w. j  a  v a2s . co  m

    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data")));

    byte[] byteArray = new byte[10];
    in.read(byteArray);
    System.out.println(Arrays.toString(byteArray));
    in.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeChars("java2s.com");
    out.close();//from   ww w .j a  v a2  s.  com

    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data")));

    byte[] byteArray = new byte[10];
    in.read(byteArray);
    System.out.println(Arrays.toString(byteArray));
    in.close();
}

From source file:Main.java

public static void main(String[] args) throws Exception {

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeDouble(1.234);/*w ww. j av  a 2 s  .com*/
    out.close();

    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data")));

    byte[] byteArray = new byte[10];
    in.read(byteArray);
    System.out.println(Arrays.toString(byteArray));
    in.close();
}