Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parser old version
@TargetApi(Build.VERSION_CODES.O)
public static void write(File rootDir) throws IllegalAccessException, IOException {
Field[] declaredFields = DefaultHyphenator.HyphenPattern.class.getDeclaredFields();
List<Field> staticFields = new ArrayList<Field>();
for (Field field : declaredFields) {
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
staticFields.add(field);
}
}
for (Field field : staticFields) {
File file = new File(rootDir, field.getName() + ".hyp");
DefaultHyphenator.HyphenPattern hyphenPattern = (DefaultHyphenator.HyphenPattern) field.get(null);
StringBuilder sb = new StringBuilder();
sb.append(hyphenPattern.leftMin)
.append(' ')
.append(hyphenPattern.rightMin)
.append('\n');
for (Map.Entry<Integer, String> one : hyphenPattern.patternObject.entrySet()) {
sb.append(one.getKey()).append(' ').append(one.getValue()).append('\n');
}
file.delete();
file.createNewFile();
Files.write(file.toPath(), sb.toString().getBytes(), StandardOpenOption.WRITE);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment