Package pixy.io

Class PeekHeadInputStream

java.lang.Object
java.io.InputStream
pixy.io.PeekHeadInputStream
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class PeekHeadInputStream
extends java.io.InputStream
Lightweight stream wrapper which allows to peek a fixed length of bytes from the current stream head
  • Constructor Summary

    Constructors 
    Constructor Description
    PeekHeadInputStream​(java.io.InputStream src, int bytesToPeek)  
  • Method Summary

    Modifier and Type Method Description
    void close()  
    byte[] peek​(int len)  
    int read()  
    int read​(byte[] b, int off, int len)  
    void shallowClose()  

    Methods inherited from class java.io.InputStream

    available, mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PeekHeadInputStream

      public PeekHeadInputStream​(java.io.InputStream src, int bytesToPeek)
      Parameters:
      bytesToPeek - number of bytes to peek
      src - The source InputStream to use
  • Method Details

    • close

      public void close() throws java.io.IOException
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Overrides:
      close in class java.io.InputStream
      Throws:
      java.io.IOException
    • shallowClose

      public void shallowClose() throws java.io.IOException
      Throws:
      java.io.IOException
    • peek

      public byte[] peek​(int len) throws java.io.IOException
      Throws:
      java.io.IOException
    • read

      public int read() throws java.io.IOException
      Specified by:
      read in class java.io.InputStream
      Throws:
      java.io.IOException
    • read

      public int read​(byte[] b, int off, int len) throws java.io.IOException
      Overrides:
      read in class java.io.InputStream
      Throws:
      java.io.IOException