package de.siphalor.was.util;

import org.jetbrains.annotations.NotNull;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * <b>Taken from here: https://stackoverflow.com/questions/924990/how-to-cache-inputstream-for-multiple-use#1303314</b>
 */
public class PersistentInputStream extends BufferedInputStream {
	public PersistentInputStream(@NotNull InputStream in) {
		super(in);
		super.mark(Integer.MAX_VALUE);
	}

	@Override
	public void close() throws IOException {
		super.reset();
	}

	public void realClose() throws IOException {
		super.close();
	}
}
