void (@NotNull String encoding, @NotNull ThrowableRunnable<?> r) { Charset.forName(encoding); // check the encoding exists try { Charset oldCharset = Charset.defaultCharset(); try { patchSystemFileEncoding(encoding); r.run(); } finally { patchSystemFileEncoding(oldCharset.name()); } } catch (Throwable t) { throw new RuntimeException(t); } }