Class Strings
public final class Strings
This class provides methods to manage and retrieve localized strings from resource bundles. It supports different encodings and allows fetching
strings with or without formatting arguments.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the default resource bundle contains the specified key.booleanChecks if the specified resource bundle contains the specified key.Retrieves the localized string for the specified key from the default resource bundle.Retrieves the localized string for the specified key from the default resource bundle, with optional formatting arguments.Retrieves the localized string for the specified key from the specified resource bundle, with optional formatting arguments.String[]Get a list of strings from the specified raw text files.voidsetEncoding(Charset charset) Sets the character encoding to be used for reading resource bundles.
-
Field Details
-
DEFAULT_BUNDLE
- See Also:
-
-
Method Details
-
setEncoding
Sets the character encoding to be used for reading resource bundles.- Parameters:
charset- The character encoding to set.
-
get
-
get
Retrieves the localized string for the specified key from the default resource bundle, with optional formatting arguments.- Parameters:
key- The key for the desired string.args- The arguments to format the string with.- Returns:
- The localized string corresponding to the specified key, formatted with the provided arguments, or null if the key is null.
-
getFrom
Retrieves the localized string for the specified key from the specified resource bundle, with optional formatting arguments.- Parameters:
bundleName- The name of the resource bundle to retrieve the string from.key- The key for the desired string.args- The arguments to format the string with.- Returns:
- The localized string corresponding to the specified key, formatted with the provided arguments, or the key itself if the resource is not found.
-
getList
Get a list of strings from the specified raw text files. Strings are separated by a new line.
This method is not cached. Ever call will open up a new
InputStreamto read the strings from the text file.- Parameters:
textFile- The text file that will be retrieved.- Returns:
- A list with all strings that are contained by the text file.
-
contains
Checks if the default resource bundle contains the specified key.- Parameters:
key- The key to check for.- Returns:
- True if the key is found in the default resource bundle, false otherwise.
-
contains
Checks if the specified resource bundle contains the specified key.- Parameters:
bundleName- The name of the resource bundle to check.key- The key to check for.- Returns:
- True if the key is found in the specified resource bundle, false otherwise.
-