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

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