1

Since JDK8, mature java.util.Base64 APIs have been added.

The only methods to stream process InputStream(s) and OutputStream(s) are, respectively:

  • Base64.get*Decoder().wrap(is)
  • Base64.get*Encoder().wrap(os).

How can I encode an InputStream or decode and OuputStream using only Java APIs in an efficient way?

Is there a reason those methods have not been added to Java APIs?

This functionality is present, for example, in net.iharder.base64, but I was migrating to Java APIs in order to remove that dependency.

Jhack
  • 510
  • 1
  • 6
  • 20
  • I suppose, this has been considered rarely needed. Can you describe your actual use case? – Holger Oct 12 '17 at 10:39
  • Well, if the API only wants to decode InputStreams and encode OutputStreams you have to "convert" them: https://stackoverflow.com/questions/5778658/how-to-convert-outputstream-to-inputstream – Robert Oct 12 '17 at 13:44

0 Answers0