package innovimax.mixthem.io;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class MultiChannelCharReader implements IMultiChannelCharInput {
	
	private final List<ICharInput> readers = new ArrayList<ICharInput>();
	
	public MultiChannelCharReader(final List<InputResource> inputs) {
		inputs.stream().forEach(input -> {
			try {
				this.readers.add(new DefaultCharReader(input));
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		});
	}
	
	@Override
	public boolean hasCharacter() throws IOException {
		final Iterator<ICharInput> iterator = this.readers.iterator();
		while (iterator.hasNext()) {
			final ICharInput reader = iterator.next();
			if (reader.hasCharacter()) {
				return true;
			}
		}
		return false;
	}
	
	@Override
	public int[] nextCharacterRange() throws IOException {
		final int[] chars = new int[this.readers.size()];
		int channel = 0;
		final Iterator<ICharInput> iterator = this.readers.iterator();
		while (iterator.hasNext()) {
			final ICharInput reader = iterator.next();
			final int c = reader.nextCharacter();
			chars[channel++] = c;
		}
		return chars;
	}

	@Override
	public void close() throws IOException {
		final Iterator<ICharInput> iterator = this.readers.iterator();
		while (iterator.hasNext()) {
			final ICharInput reader = iterator.next();
			reader.close();
		}		
	}
	
}

@@ -129,16 +129,38 @@
 il.List;
+%0Aimport java.util.Set;
 %0A%0Apublic
@@ -305,91 +305,428 @@
 %0A%09%0A%09
-public MultiChannelCharReader(final List%3CInputResource%3E inputs) %7B%0A%09%09inputs.stream()
+/**%0A%09* Constructor%0A%09* @param inputs The list of inputs as InputResource%0A%09* @param selection The input index selection (maybe empty)%0A%09* @see innovimax.mixthem.io.InputResource%0A%09*/%0A%09public MultiChannelCharReader(final List%3CInputResource%3E inputs, final Set%3CInteger%3E selection) %7B%0A%09%09IntStream.range(0, inputs.size())%0A%09%09%09.filter(index -%3E selection.contains(Integer.valueOf(index)))%0A%09%09%09.mapToObj(index -%3E inputs.get(index))%0A%09%09%09
 .for
@@ -748,14 +748,16 @@
 %0A%09%09%09
+%09
 try %7B%0A
+%09
 %09%09%09%09
@@ -784,20 +784,20 @@
  Default
-Char
+Byte
 Reader(i
@@ -804,16 +804,17 @@
 nput));%0A
+%09
 %09%09%09%7D cat
@@ -830,24 +830,25 @@
 eption e) %7B%0A
+%09
 %09%09%09%09throw ne
@@ -873,18 +873,20 @@
 (e);%0A%09%09%09
+%09
 %7D%0A
+%09
 %09%09%7D);%0A%09%7D

Update MultiChannelCharReader.java