Class StreamUtils

java.lang.Object
net.solarnetwork.io.StreamUtils

public final class StreamUtils extends Object
Stream utilities.
Since:
2.3
Version:
1.0
Author:
matt
  • Field Details

    • GZIP_MAGIC

      public static final int GZIP_MAGIC
      The "magic bytes" to look for at the start of a GZIP stream.
      See Also:
  • Constructor Details

    • StreamUtils

      public StreamUtils()
  • Method Details

    • inputStreamForPossibleGzipStream

      public static InputStream inputStreamForPossibleGzipStream(InputStream in) throws IOException
      Get an InputStream for a given stream with automatic GZIP detection.

      If in is already a GZIPInputStream then it will be returned directly. Otherwise he given stream will be read just enough to determine if it looks like a GZIP stream. If it does, then a new GZIPInputStream will be returned.

      Parameters:
      in - the input stream to wrap
      Returns:
      the appropriate input stream, never null
      Throws:
      IOException - if any IO error occurs