Parser old version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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