package innovimax.mixthem.operation;

import innovimax.mixthem.MixException;
import innovimax.mixthem.arguments.RuleParam;
import innovimax.mixthem.arguments.ParamValue;
import innovimax.mixthem.io.DefaultByteReader;
import innovimax.mixthem.io.DefaultByteWriter;
import innovimax.mixthem.io.IInputByte;
import innovimax.mixthem.io.IOutputByte;
import innovimax.mixthem.io.InputResource;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

/**
* <p>Abstract class for all byte operation.</p>
* @see IByteOperation
* @author Innovimax
* @version 1.0
*/
public abstract class AbstractByteOperation extends AbstractOperation implements IByteOperation {

	/**
	* Constructor
 	* @param params The list of parameters (maybe empty)
	* @see innovimax.mixthem.arguments.RuleParam
	* @see innovimax.mixthem.arguments.ParamValue
	*/
	public AbstractByteOperation(final Map<RuleParam, ParamValue> params) {
		super(params);
	}

    @Override
    public void processFiles(final List<InputResource> inputs, final OutputStream output) throws MixException, IOException {
		final IInputByte reader1 = new DefaultByteReader(inputs.get(0));
		final IInputByte reader2 = new DefaultByteReader(inputs.get(1));
		final IOutputByte writer = new DefaultByteWriter(output);
		final ByteResult result = new ByteResult();
		while (reader1.hasByte() || reader2.hasByte()) {
			final byte b1 = reader1.nextByte();
			final byte b2 = reader2.nextByte();			
			process(b1, b2, result);			
			if (result.hasResult()) {
				result.getResult().forEach(i -> {
					try {						
						writer.writeByte((byte) i);
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				});
			}
        }
        reader1.close();
        reader2.close();
        writer.close();
    }

}

@@ -1102,17 +1102,20 @@
 tion %7B%0A%09
-%09
+    
 final II
@@ -1168,25 +1168,28 @@
 s.get(0));%0A%09
-%09
+    
 final IInput
@@ -1238,25 +1238,28 @@
 s.get(1));%0A%09
-%09
+    
 final IOutpu
@@ -1305,17 +1305,20 @@
 tput);%0A%09
-%09
+    
 final By
@@ -1354,17 +1354,20 @@
 ult();%0A%09
-%09
+    
 while (r
@@ -1409,17 +1409,20 @@
 ()) %7B%0A%09%09
-%09
+    
 final by
@@ -1451,17 +1451,20 @@
 te();%0A%09%09
-%09
+    
 final by
@@ -1490,23 +1490,23 @@
 tByte();
-%09%09%09%0A%09%09%09
+%0A%09%09    
 process(
@@ -1521,23 +1521,23 @@
 result);
-%09%09%09%0A%09%09%09
+%0A%09%09    
 if (resu
@@ -1557,17 +1557,20 @@
 )) %7B%0A%09%09%09
-%09
+    
 result.g
@@ -1603,27 +1603,27 @@
 %09%09%09%09
-%09
+    
 try %7B
-%09%09%09%09%09%09
 %0A%09%09%09%09%09
-%09
+    
 writ
@@ -1650,17 +1650,20 @@
 i);%0A%09%09%09%09
-%09
+    
 %7D catch 
@@ -1685,17 +1685,20 @@
  %7B%0A%09%09%09%09%09
-%09
+    
 throw ne
@@ -1728,38 +1728,41 @@
 %09%09%09%09
-%09
+    
 %7D%0A%09%09%09
-%09
+    
 %7D);%0A%09%09
-%09%7D%0A    
     %7D%0A
+%09
     
+%7D%0A%09
     
@@ -1774,28 +1774,25 @@
 r1.close();%0A
-    
+%09
     reader2.
@@ -1800,20 +1800,17 @@
 lose();%0A
-    
+%09
     writ

Update AbstractByteOperation.java