There are several utilitity classes which you can use at anywhere you want.
HTTP connection utility
When you need to interact with web servers, you can use HTTP connection utility.
If you want remote resource as String,
HttpConnectionUtils#getURL is what you need.
There are two variants;
getURL(URL url, int timeout)
A default timeout is 10 seconds.
When you need to download binary file from remote, you can use
downloadBinary utility method.
downloadBinaryFile(URL fileURL, Map<String, String> headers, Set<String> expectedMime, File saveFilePath)
It will return
true when successfully download the file.
You should provide headers, and expected MIME types.
When you need to download zip file from remote and extract its contents, use can use
downloadZipFileAndExtract(URL url, File dir, List<String> expectedFiles)
It takes target directory and expected filename list.
These utilities use
URL#openConnection method. It looks system property for proxy connections.
There are also some primitive connection utilities.
When you handle HTML text, you will need to convert HTML excape characters into UTF-8.
HTMLUtils#entitiesToChars is what you want.
There is also a
HTMLUtils#charsToEntities which does reverse things.
When we read arbitrary text files from disk, we sometimes need to detect character encodings.
EncodingDetector#detectEncoding is one we used in glossary reader.
When there are enough characters, it detects an encoding correctly.
There are also a variant
detectEndocingDefault that accept default encoding.
There are some small utilities in
getConfigDir: get omegat configuration directory such as
installDir: get omegat installation directory where
getScriptDir: get directory where scripts are installed.
There are several must use utility methods in
isEmpty(@Nullable String str): check string is null or empty string("")
isCJK: return true when string has characters in Chinese, Japanese, or Korean.
capitalizeFirst: convert string with First character as upper case.
toTitleCase:convert string as title case.
When you need to detect a platform where OmegaT running on, such as Windows, macOS or Linux.
There is a utility class
Platform for the purpose. There are boolean constants to indicate
the platform type.
There are also some informational constants.
It also provides hints about an architecture.
It must be useful.
Also provide some functions.
Platform.is64Bit(): true when OemgaT run on 64bit OS platform.