public static boolean isPEM(byte[] byteArray){
  try {
    String startPEM="-----BEGIN";
    int headerLength=100;
    byte[] preamble=new byte[headerLength];
    System.arraycopy(byteArray,0,preamble,0,headerLength);
    String startArray=new String(preamble);
    return startArray.startsWith(startPEM);
  }
 catch (  Exception e) {
    throw new DSSException("Unable to read InputStream");
  }
}

public static boolean isPEM ( byte [ ] byteArray ) { try { String startPEM = "-----BEGIN" ; int headerLength = 100 ; byte [ ] preamble = new byte [ headerLength ] ; System . arraycopy ( byteArray , 0 , preamble , 0 , headerLength ) ; String startArray = new String ( preamble ) ; return startArray . startsWith ( startPEM ) ; } catch ( Exception e ) { throw new DSSException ( "Unable to read InputStream" ) ; } }
this method returns true if the bytearray contains a pem encoded item
