code: public void writeTo(String file) throws IOException {
      	File privateKey = FileUtil.createFile(file);
          // JGLOBUS-96
          try{
          	privateKey.setReadable(false, true);//setOwnerAccessOnly(file);
          	privateKey.setWritable(false, true);//setOwnerAccessOnly(file);
          }catch(SecurityException e){
  
          }
          PrintWriter p = new PrintWriter(new FileOutputStream(privateKey));
  
          try {
              p.write(toPEM());
          } finally {
              p.close();
          }
      }
docs: Writes the private key to the specified file in PEM format.
  If the key was encrypted it will be encoded as an encrypted
  RSA key. If not, it will be encoded as a regular RSA key.
  
  @param file file to write the key to.
  @throws IOException if I/O problems writing the key