import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;

public class EncodingBug {
    public static void main(String[] args) throws IOException {
        test("\u00f6\u00fc\u20ac"); // OK, chars of windows-1252
// fails:
        test("\u041e");
        test("\u0080");
        test("\u0080\u041e");
    }

    private static void test(String s) throws IOException {
        Path file = Files.createTempFile("prefix", "suffix");
        Charset charset = Charset.forName("windows-1252");
// Charset charset = StandardCharsets.ISO_8859_1; -> UnmappableCharacterException
        Files.writeString(file, s, charset); // should throw IOException (UnmappableCharacterException)!!
        String s2 = Files.readString(file, charset);
        System.out.println("s.equals(s2): "+s.equals(s2));
    }
} 