code: public static void saveProxyCredentials(String proxyFileName,
      X509Credential uc, PrivateKeyEncoding encoding) 
        throws IOException {
  
      File f = new File(proxyFileName);
      RandomAccessFile raf = new RandomAccessFile(f, "rws");
      FileChannel channel = raf.getChannel();
      FilePermissionHelper.setProxyPermissions(proxyFileName);
      channel.truncate(0);
  
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      saveProxyCredentials(baos, uc, encoding);
  
      baos.close();
      channel.write(ByteBuffer.wrap(baos.toByteArray()));
  
      channel.close();
      raf.close();
    }
docs: Saves proxy credentials to a file. This method ensures that the stored
  proxy is saved with the appropriate file permissions.
  
  @param proxyFileName
  the file where the proxy will be saved
  @param uc
  the credential to be saved
  @param encoding
  the private key encoding
  @throws IOException
  in case of errors writing to the proxy file