package com.aps.common.util;

import java.io.OutputStream;
import java.io.PrintStream;

/**
 * 作者：佟礼
 * 时间：2026-07-24
 */
 public class TeePrintStream extends PrintStream {
    private final PrintStream other;

    public TeePrintStream(OutputStream main, PrintStream other) {
        super(main);
        this.other = other;
    }

    @Override
    public void write(int b) {
        super.write(b);
        other.write(b);
    }

    @Override
    public void write(byte[] buf, int off, int len) {
        super.write(buf, off, len);
        other.write(buf, off, len);
    }

    @Override
    public void flush() {
        super.flush();
        other.flush();
    }

    @Override
    public void close() {
        super.close();
        other.close();
    }
}
