package innovimax.mixthem.io;

import innovimax.mixthem.interfaces.IInputChar;

import java.io.File;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
* <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;
	private boolean jump;

	/**
 	* Creates a character reader.
 	* @param file The input file to be read
 	* @throws IOException - If an I/O error occurs
 	*/
	public DefaultCharReader(File input, boolean first) throws IOException {		
		this.reader = new BufferedReader(new FileReader(input));
		this.jump = !first;		
	}

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

	@Override
	public int nextCharacter(ReadType type, boolean force) throws IOException {		
		int c = -1;
		if (hasCharacter()) {
			switch (type) {
				case _ALT_SIMPLE:
					if (!this.jump || force) {
						c = this.reader.read();
					} else {
						this.reader.read();
					}					
					this.jump = !this.jump;
					break;				
			}
		}
		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();
	}

}

@@ -140,26 +140,69 @@
 java.io.
-FileReader
+IOException;%0Aimport java.nio.charset.StandardCharsets
 ;%0Aimport
@@ -207,30 +207,57 @@
 rt java.
+n
 io.
-IOException
+file.Files;%0Aimport java.nio.file.Path
 ;%0A%0A/**%0A*
@@ -481,16 +481,42 @@
 Char %7B%0A%0A
+%09private final Path path;%0A
 %09private
@@ -617,20 +617,21 @@
  @param 
-file
+input
  The inp
@@ -649,16 +649,70 @@
 be read%0A
+ %09* @param first True is this reader is the first one%0A
  %09* @thr
@@ -833,16 +833,46 @@
 ion %7B%09%09%0A
+%09%09this.path = input.toPath();%0A
 %09%09this.r
@@ -879,20 +879,25 @@
 eader = 
+Files.
 new
- 
 Buffered
@@ -907,55 +907,282 @@
 der(
-new FileReader(input));%0A%09%09this.jump = !first;%09%09
+path, StandardCharsets.UTF_8);%0A%09%09this.jump = !first;%0A%09%7D%0A%0A%09/**%0A %09* Creates a character reader.%0A %09* @param input The input file to be read %09%0A %09* @throws IOException - If an I/O error occurs%0A %09*/%0A%09public DefaultCharReader(File input) throws IOException %7B%09%09%0A%09%09this(input, true);
 %0A%09%7D%0A

Update DefaultCharReader.java