Code example for ByteArrayInputStream

Methods: read

0
  } 
 
  @Override 
  public Credential unserializeCredential(byte[] data) { 
    try { 
      ByteArrayInputStream bais = new ByteArrayInputStream(data); 
      int header = bais.read(); 
      if(header != magicHeader()) { 
        throw new RuntimeException("Cannot unserialize this credential: header was " + header + 
          " expected header " + magicHeader()); 
      } 
      ObjectInputStream objectInput = new ObjectInputStream(bais); 
      return (Credential) objectInput.readObject(); 
    } catch (Exception e) { 
      throw new RuntimeException(e); 
    } 
  } 
 
  @Override 
  public int magicHeader() { 
    return 0x03;