Skip to content

Instantly share code, notes, and snippets.

@Crydust
Created January 20, 2016 09:41
Show Gist options
  • Save Crydust/7d9df6c4d82db69bdae3 to your computer and use it in GitHub Desktop.
Save Crydust/7d9df6c4d82db69bdae3 to your computer and use it in GitHub Desktop.
private static Properties readUtf8Properties(Path path) throws IOException {
final Properties properties = new Properties();
final int UTF8_BOM = (int) '\uFEFF';
try (final BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
reader.mark(1);
if (reader.read() != UTF8_BOM) {
reader.reset();
}
properties.load(reader);
}
return properties;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment