Skip to content

Instantly share code, notes, and snippets.

@LionZXY
Created April 10, 2018 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LionZXY/171ab2bc25a6d134ff1c3f190bd6e9e9 to your computer and use it in GitHub Desktop.
Save LionZXY/171ab2bc25a6d134ff1c3f190bd6e9e9 to your computer and use it in GitHub Desktop.
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