List of usage examples for java.io ObjectOutputStream writeShort
public void writeShort(int val) throws IOException
From source file:Main.java
public static void main(String[] args) throws Exception { short b = 32767; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); // write something in the file oout.writeShort(b); oout.flush();//from w w w . j av a2 s .co m oout.close(); // create an ObjectInputStream for the file we created before ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); // read and print the short System.out.println(ois.readUnsignedShort()); ois.close(); }
From source file:Main.java
public static void main(String[] args) throws Exception { short s = 56; FileOutputStream out = new FileOutputStream("test.txt"); ObjectOutputStream oout = new ObjectOutputStream(out); // write something in the file oout.writeShort(s); oout.writeShort(new Short("1")); oout.flush();/*ww w .java2s . com*/ oout.close(); // create an ObjectInputStream for the file we created before ObjectInputStream ois = new ObjectInputStream(new FileInputStream("test.txt")); // read and print a short System.out.println(ois.readShort()); // read and print a short System.out.println(ois.readShort()); ois.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); out.close();/* w w w . j a va 2 s. c om*/ 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:ShortArrayList.java
private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject();//from w ww . j av a 2 s . c o m out.writeInt(array.length); for (int i = 0; i < size; i++) { out.writeShort(array[i]); } }
From source file:org.spout.api.inventory.ItemStack.java
private void writeObject(java.io.ObjectOutputStream out) throws IOException { out.writeShort(material.getId()); out.writeShort(material.getData());/* w w w . java 2s . c o m*/ out.writeInt(amount); out.writeShort(data); byte[] auxData = this.auxData.serialize(); if (auxData != null) { out.writeInt(auxData.length); out.write(auxData); } else { out.writeInt(0); } if (nbtData != null && !nbtData.isEmpty()) { out.writeBoolean(true); NBTOutputStream os = new NBTOutputStream(out, false); os.writeTag(new CompoundTag("nbtData", nbtData)); os.close(); } else { out.writeBoolean(false); } }