In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to use ResourceBundle of Java". In daily operation, I believe many people have doubts about how to use ResourceBundle of Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use ResourceBundle of Java". Next, please follow the editor to study!
The string written in the program is put into the configuration file through ResourceBundle, and internationalization can be easily realized at the same time.
A data validation technique that combines regular expressions with Java ResourceBundle. The Java language's support for regular expressions can greatly simplify data validation. You
You can compare data with regular expressions, and if they match, you know that the data is valid. Java ResourceBundle, on the other hand, contains translated words
String to match the current language and country settings on the user's machine. Strings in ResourceBundle are usually text that appears in the application, but you can also
So anything specific to a region.
one. Extract the string
Generate ResourceBundle-related classes and files through Eclipse's source- "Externalize String
The answer depends on how ResourceBundle is created.
Whenever a Java program is run, it has a specific locale. The region is specified by a two-letter language code and a two-letter country code, which
Is defined by the ISO standard. The locale code also has an uncommonly used variant section that is used to specify a specific locale more accurately. Here are some examples:
En_US is the English area.
En_CA is the Canadian English area.
Fr_CA is the French Canadian area.
En is the English area.
En_US_UNIX is a variety of UNIX in the English region. As for the meaning and usage of the variant, it is defined by the author of the application.
When you create a new ResourceBundle, the Java runtime looks for files based on the current locale. For example, if the current locale is en_US, then Java runs
Look for the following files in turn:
Messages_en_US.properties
Messages_en.properties
Messages.properties
When ResourceBundle collects translated strings, any string found in messages_en_US.properties has a ratio to
Strings with the same name in messages_en.properties and messages.properties have a higher priority. If the runtime does not find anything specific to the
Locale, then it will use the string in messages.properties.
Remember, the code that created the ResourceBundle specifies the file name messages.properties. The file name does not change with the region, and the code does not need to be changed.
Change. You only need to specify this file name, and the Java runtime can automatically figure out which locale-specific files should be loaded.
A locale-specific .properties file contains only strings that are different from the more generic .properties file
Set the locale at run time:
The first method is to set the user.language and user.country system properties when running the application
Java-Duser.language=XXX-Duser.country=XX
The second way is to set the locale in the application. You can set the default locale in your code through the Locale.setDefault () method.
Swing provides the javax.swing.JFormattedTextField class. Use this class to define a mask for the text field
At this point, the study on "how to use the ResourceBundle of Java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.