This document helps users migrate between versions of OpenCC Java.
- In v1.0.3, each
OpenCCinstance could load its own dictionary. - In v1.1.0, dictionaries are now loaded once per JVM (via
DictionaryHolder) and shared by all instances.
- Faster startup (dictionary parsing happens only once).
- Lower memory usage (one dictionary in memory instead of one per instance).
- Ideal for GUI applications (e.g. JavaFX) and helpers (e.g.
OfficeHelper).
- INFO log: dictionary loaded from file system or embedded resource.
- WARNING log: dictionary fallback to plain-text sources.
Any modifications will affect all OpenCC instances in the same JVM.
-
In v1.0.3,
zhoCheckwas an instance method:OpenCC cc = new OpenCC("s2t"); int result = cc.zhoCheck("汉字");
-
In v1.1.0,
zhoCheckis a static method:
int result = OpenCC.zhoCheck("汉字"); // preferred- For backward compatibility, use
zhoCheckInstance:
OpenCC cc = new OpenCC("s2t");
int result = cc.zhoCheckInstance("汉字");Use the static dictionary for performance:
OpenCC cc = new OpenCC("s2t"); // shares dictionary
String converted = cc.convert("汉字");Pass the OpenCC instance:
OpenCC instance = new OpenCC("s2t");
OfficeHelper.Resault result = OfficeHelper.convert(inputPath, outputPath, "docx", instance, /* punctuation */ true, /* keepFont */ true);If you need to load a custom dictionary path, use the deprecated constructor:
OpenCC custom = new OpenCC("s2t", Paths.get("my_dicts"));This loads a private dictionary for that instance only. It is slower and uses more memory but allows per-instance customization.
- Default: use static dictionary +
OpenCC.zhoCheck(). - Compatibility: use
zhoCheckInstance(). - Custom dictionary: use the deprecated
(config, Path)constructor.