Package java.io

Examples of java.io.ObjectInputStream.available()


      int available1 = 0;
      int available2 = 0;
      Object obj1 = null;
      Object obj2 = null;
      ObjectInputStream ois = new ObjectInputStream(loadStream());
      available1 = ois.available();
      obj1 = ois.readObject();
      available2 = ois.available();
      obj2 = ois.readObject();

      assertEquals("available returned incorrect value", 0, available1);
View Full Code Here


      Object obj1 = null;
      Object obj2 = null;
      ObjectInputStream ois = new ObjectInputStream(loadStream());
      available1 = ois.available();
      obj1 = ois.readObject();
      available2 = ois.available();
      obj2 = ois.readObject();

      assertEquals("available returned incorrect value", 0, available1);
      assertEquals("available returned incorrect value", 0, available2);
View Full Code Here

      assert in.read() == CacheMarshaller200.MAGICNUMBER_MARSHALLEDVALUE;
      MarshalledValue recreated = new MarshalledValue();
      recreated.readExternal(in);

      // there should be nothing more
      assert in.available() == 0;
      in.close();
      bin.close();

      assertSerialized(recreated);
      assert recreated.equals(mv);
View Full Code Here

    final Object object = objectStream.readObject ();
    if (!this.nullAllowed && (object == null))
      throw (new IOException ("unexpected null object"));
    if (!this.clasz.isInstance (object))
      throw (new IOException (String.format ("unexpected object class: `%s`", object.getClass ())));
    if (objectStream.available () > 0)
      throw (new IOException ("trailing garbage after object"));
    return (this.clasz.cast (object));
  }
 
  @Override
View Full Code Here

        ois = new ObjectInputStream(bais);
      } else {
        ois = new CustomClassLoaderObjectInputStream(classLoader, bais);
      }
      Object obj = ois.readObject();
      bytes.position(bytes.position() + (l - ois.available()));
      ois.close();
      return obj;
    } catch (Exception ex) {
      throw new HectorSerializationException(ex);
    }
View Full Code Here

            if (path.exists())
            {
                if (logger.isDebugEnabled())
                    logger.debug(String.format("reading saved cache from %s", path));
                ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream(path)));
                while (in.available() > 0)
                {
                    int size = in.readInt();
                    byte[] bytes = new byte[size];
                    in.readFully(bytes);
                    keys.add(StorageService.getPartitioner().decorateKey(ByteBuffer.wrap(bytes)));
View Full Code Here

            int l = dup.remaining();
            ByteArrayInputStream bais = new ByteArrayInputStream(dup.array(),
                    dup.arrayOffset() + dup.position(), l);
            ObjectInputStream ois = new ObjectInputStream(bais);
            Object obj = ois.readObject();
            dup.position(dup.position() + (l - ois.available()));
            ois.close();
            return obj;
        } catch (Exception ex) {
            throw new SerializationException(ex);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.