List of usage examples for java.io ObjectInputStream readShort
public short readShort() throws IOException
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);/* w ww .j av a 2 s .c o m*/ oout.writeShort(new Short("1")); oout.flush(); 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:ShortArrayList.java
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();//from w ww . j a v a 2 s. co m array = new short[in.readInt()]; for (int i = 0; i < size; i++) { array[i] = in.readShort(); } }
From source file:org.datanucleus.store.hbase.fieldmanager.FetchFieldManager.java
private short fetchShortInternal(AbstractMemberMetaData mmd, byte[] bytes) { short value;//from ww w. j av a2 s.co m if (bytes == null) { // Handle missing field String dflt = HBaseUtils.getDefaultValueForMember(mmd); if (dflt != null) { return Short.valueOf(dflt).shortValue(); } return 0; } if (mmd.isSerialized()) { try { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bis); value = ois.readShort(); ois.close(); bis.close(); } catch (IOException e) { throw new NucleusException(e.getMessage(), e); } } else { value = Bytes.toShort(bytes); } return value; }
From source file:org.spout.api.inventory.ItemStack.java
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { short matId = in.readShort(); short matData = in.readShort(); material = MaterialRegistry.get(matId); if (matData != 0 && material != null) { material = material.getSubMaterial(matData); }/*from w w w. j a v a 2 s .com*/ amount = in.readInt(); data = in.readShort(); int auxDataSize = in.readInt(); if (auxDataSize > 0) { byte[] auxData = new byte[auxDataSize]; ManagedHashMap map = new ManagedHashMap(); map.deserialize(auxData); this.auxData = map; } boolean hasNBTData = in.readBoolean(); if (hasNBTData) { NBTInputStream is = new NBTInputStream(in, false); CompoundTag tag = (CompoundTag) is.readTag(); nbtData = tag.getValue(); is.close(); } if (material == null) { throw new ClassNotFoundException("No material matching {" + matId + ", " + matData + "} was found!"); } }