Example usage for java.io ObjectInputStream read

List of usage examples for java.io ObjectInputStream read

Introduction

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

Prototype

public int read(byte b[]) throws IOException 

Source Link

Document

Reads some number of bytes from the input stream and stores them into the buffer array b.

Usage

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  ava2s.c  o  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();/*w w w. ja  v a 2s . c o  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.writeDouble(1.234);/* w  w  w. java 2 s. c  o m*/
    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();
}

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(1);/*  w  w w. ja  v a2 s.  co m*/
    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();
}

From source file:Main.java

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

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeShort(1);// ww  w  . java  2  s .  co m
    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();
}

From source file:Main.java

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

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeBoolean(true);/*from   ww w.java 2s . c o m*/
    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();
}

From source file:Main.java

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

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeBytes("java2s.com");
    out.close();//from  w  ww.  j  a v  a2  s .  c  o  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.writeByte(1);/*from   ww  w  .  j  av a  2s. c  o  m*/
    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();
}

From source file:Main.java

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

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeFloat(1.234F);/*  w  w  w .  j a va2s  .  c  o  m*/
    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();
}

From source file:Main.java

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

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeChar(100);/*from w ww  .j  a v 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();
}