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()); 
      } 
      return (Credential) XmlUtils.getObjectFromXML(bais, true);
    } catch (Exception e) {
      throw new RuntimeException(e);
    } 
  } 
 
  @Override 
  public int magicHeader() { 
    return 0x01; 
  }