Java tutorial
import java.io.FileInputStream; import java.io.PushbackInputStream; public class Main { public static void main(String[] args) { String srcFile = "test.txt"; try (PushbackInputStream pis = new PushbackInputStream(new FileInputStream(srcFile))) { byte byteData; while ((byteData = (byte) pis.read()) != -1) { System.out.print((char) byteData); pis.unread(byteData); // Reread the byte we unread byteData = (byte) pis.read(); System.out.print((char) byteData); } } catch (Exception e2) { e2.printStackTrace(); } } }