title: How to decode a .csr file in java to extract its content
body: <p>I have three kinds of files to decode namely .csr and .der and .key files.I am able to decode .der file using the java as below.
  public class Base64Decoder {</p>
  
  <pre><code>public static void main(String[] args) throws FileNotFoundException, IOException {
      Certificate cert=null;
  try{
  
   FileInputStream fis = new FileInputStream("C:/Users/patillat/Downloads/device-ee/csr/00db1234567890A5-ka.der");
   BufferedInputStream bis = new BufferedInputStream(fis);
  
   CertificateFactory cf = CertificateFactory.getInstance("X.509");
  
   while (bis.available() &gt; 0) {
      cert = cf.generateCertificate(bis);
      try {
          System.out.println("-----BEGIN CERTIFICATE-----");
          System.out.println(DatatypeConverter.printBase64Binary(cert.getEncoded()));
          System.out.println("-----END CERTIFICATE-----");
          //System.out.println("key:"+cert.getPublicKey());
      } catch (CertificateEncodingException e) {
          e.printStackTrace();
      }
      System.out.println(cert.toString());
   }
  }
  catch(Exception e)
  {
      e.printStackTrace();
  }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am able to generate details of .der certificate</p>
  
  <p>In the same way I am not able to decode my .csr file.
  Are there any other ways to decode .csr files?</p>