package cn.iocoder.yudao.module.infra.util;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.Enumeration;
import java.util.Vector;

public class InputStreamConverter {
    public static InputStream convertByteArrayInputStreamArrayToInputStream(ByteArrayInputStream[] ins) {
        Vector<InputStream> inputStreams = new Vector<>();
        for (ByteArrayInputStream byteArrayInputStream : ins) {
            inputStreams.add(byteArrayInputStream);
        }
        return new SequenceInputStream(new Enumeration<InputStream>() {
            private final Enumeration<InputStream> enumeration = inputStreams.elements();

            @Override
            public boolean hasMoreElements() {
                return enumeration.hasMoreElements();
            }

            @Override
            public InputStream nextElement() {
                return enumeration.nextElement();
            }
        });
    }
}
