package innovimax.mixthem.io;

import java.io.File;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

/**
* <p>Reads characters from a character-input file.</p>
* <p>This is the default implementation of IInputChar.</p>
* @see IInputChar
* @author Innovimax
* @version 1.0
*/
public class DefaultCharReader implements IInputChar {

	private final BufferedReader reader;

	/**
 	* Creates a character reader from an input resource.
 	* @param input The input resource to be read
 	* @throws IOException - If an I/O error occurs
 	*/
	public DefaultCharReader(InputResource input) throws IOException {		
		this.reader = input.newBufferedReader();
	}

	@Override
	public boolean hasCharacter() throws IOException {
		return this.reader.ready();
	}

	@Override
	public int nextCharacter() throws IOException {		
		int c = -1;
		if (hasCharacter()) {
			c = this.reader.read();
		}
		return c;
	}

	@Override
	public int nextCharacters(char[] buffer, int len) throws IOException {
		return this.reader.read(buffer, 0, len);		
	}

	@Override
	public void close() throws IOException {
		this.reader.close();
	}

}

@@ -28,29 +28,8 @@
 o;%0A%0A
-import java.io.File;%0A
 impo
@@ -75,150 +75,18 @@
 io.I
-nputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.io.IOException;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.nio.file.Files
+OException
 ;%0A%0A/

Update DefaultCharReader.java