class NormalizingStreamV8 extends InputStream {
    private ByteArrayInputStream headerStream;
    private PushbackInputStream stream;

    private byte[] quickBuffer = new byte[100];
    private List<Byte> resizingBuffer = new ArrayList<>();
    private int lastChar = 'X';
    private boolean seenNonSpace;

    @Deprecated
    public NormalizingStreamV8(String endDelimiter, Boolean splitStatements, Boolean stripComments, InputStream stream) {
        this.stream = new PushbackInputStream(stream, 2048);
        try {
            this.headerStream = new ByteArrayInputStream((endDelimiter+":"+splitStatements+":"+stripComments+":").getBytes(GlobalConfiguration.OUTPUT_FILE_ENCODING.getCurrentValue()));
        } catch (UnsupportedEncodingException e) {
            throw new UnexpectedLiquibaseException(e);
        }
    }

    @Override
    public int read() throws IOException {<FILL_FUNCTION_BODY>}
    @Override
    public int available() throws IOException {
        return stream.available();
    }
    @Override
    public boolean markSupported() {
        return stream.markSupported();
    }
    @Override
    public synchronized void mark(int readLimit) {
        stream.mark(readLimit);
    }
    @Override
    public synchronized void reset() throws IOException {
        stream.reset();
    }

    private boolean isOnlyWhitespaceRemaining() throws IOException {
        try {
            int quickBufferUsed = 0;
            while (true) {
                byte read = (byte) stream.read();
                if (quickBufferUsed >= quickBuffer.length) {
                    resizingBuffer.add(read);
                } else {
                    quickBuffer[quickBufferUsed++] = read;
                }

                if (read == -1) {
                    return true;
                }
                if (!isWhiteSpace(read)) {
                    if (!resizingBuffer.isEmpty()) {

                        byte[] buf = new byte[resizingBuffer.size()];
                        for (int i=0; i< resizingBuffer.size(); i++) {
                            buf[i] = resizingBuffer.get(i);
                        }

                        stream.unread(buf);
                    }

                    stream.unread(quickBuffer, 0, quickBufferUsed);
                    return false;
                }
            }
        } finally {
            resizingBuffer.clear();
        }
    }

    private boolean isWhiteSpace(int read) {
        return (read == ' ') || (read == '\n') || (read == '\r') || (read == '\t');
    }
    @Override
    public void close() throws IOException {
        stream.close();
    }
}

        if (headerStream != null) {
            int returnChar = headerStream.read();
            if (returnChar != -1) {
                return returnChar;
            }
            headerStream = null;
        }

        int returnChar = stream.read();
        if (isWhiteSpace(returnChar)) {
            returnChar = ' ';
        }

        while ((returnChar == ' ') && (!seenNonSpace || (lastChar == ' '))) {
            returnChar = stream.read();

            if (isWhiteSpace(returnChar)) {
                returnChar = ' ';
            }
        }

        seenNonSpace = true;

        lastChar = returnChar;

        if ((lastChar == ' ') && isOnlyWhitespaceRemaining()) {
            return -1;
        }

        return returnChar;
    
<methods>public void <init>() ,public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public static java.io.InputStream nullInputStream() ,public abstract int read() throws java.io.IOException,public int read(byte[]) throws java.io.IOException,public int read(byte[], int, int) throws java.io.IOException,public byte[] readAllBytes() throws java.io.IOException,public byte[] readNBytes(int) throws java.io.IOException,public int readNBytes(byte[], int, int) throws java.io.IOException,public synchronized void reset() throws java.io.IOException,public long skip(long) throws java.io.IOException,public void skipNBytes(long) throws java.io.IOException,public long transferTo(java.io.OutputStream) throws java.io.IOException<variables>private static final int DEFAULT_BUFFER_SIZE,private static final int MAX_BUFFER_SIZE,private static final int MAX_SKIP_BUFFER_SIZE