Objective 10.2: Match the following features of the Java 2 platform with descriptions of their functionality, purpose or typical uses: Properties, Locale, ResourceBundle, Unicode, java.text package, InputStreamReader and OutputStreamWriter
The classes
- java.util.Properties configuration data, can be loaded/saved to/from a stream, can be locale specific.
- java.util.Locale a geographic/political/cultural region, simply represents it as an identifier.
- java.util.ResourceBundle all the locale specific details bundled together per locale, you can write a class that inherits from ResourceBundle or
create file with .properties extension, uses a
_lang_COUNTRY_VARIANT, eg MyResourses_en_ENG_UNIX or MyResources_ge_CH, ListResourceBundle backed with a class to deal with resources as a list, and PropertyResourceBundle deal with resources in properties files. - Formatting classes that inherit from java.text.Format to parse/format, eg: DateFormat, MessageFormat and NumberFormat
- Locale-Specific String Classes Collator = string comparison, CollationElementIterator = iterate through international strings, CollationKey = Collator key, BreakIterator = find line breaks, sentences, etc, CharacterIterator = bi-direction Iterator through Strings.
- UNICODE 2.0 (2.1) two byte chars, 16 bits.
- java.io.InputStreamReader bridge to convert a stream of non-Unicode bytes to Unicode chars. Eg:
InputStreamReader r = new InputStreamReader( new FileInputStream(test.txt),UTF8); - java.io.OutputStreamWriter bridge to convert a string of Unicode chars to non-Unicode bytes. Eg:
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("test.txt"), "UTF8")); osw.write(str);