Java ResourceBundle introduction, javaresourcebundle
Public abstract class ResourceBundle
Extends Object
Parent class of the following classes:
ListResourceBundle, PropertyResourceBundle
A resource bundle contains language-specific objects. When
The Java language provides the resourcebundle class to process resource files of the properties type.
This article provides an explanation of the resourcebundle class.
Before starting, Let's explain what resources files of the properties type are.
Public abstract class ResourceBundleExtends ObjectThe parent class of the following classes:ListResourceBundle, propertyResourceBundleResource bundles contain locale-specific objects. When a program requires a locale-specific resource, such as a
This chapter aimsMaster the basic Realization principle of internationalization procedure. Master the role of resource files. Master the basic implementation principle of the locale class. Mastering the role of the ResourceBundle class. you can use
Frameworks such as struts,spring and Tomcat containers are automatically read and resource-bound from resource files (such as Messages.properties) in a resourcebundle manner. The Java.util.ResourceBundle class is very flexible and can be
Java resourcebundle is a useful tool that can be conveniently used to implement Software Internationalization and localization functions. Because resourcebundle can automatically search for resource files (. properties files) in a certain culture
Introduction of properties File
The properties file in Java is a configuration file, mainly used to express configuration information, the file type is *.properties, the format is a text file, the file content is the format is "key = value" format,
Constants are often used in the program. If they are directly written in the program, they must be re-compiled when these strings are changed, such as the database driver, URL, user name, and password information when writing the database
Constants are often used in the program. If they are directly written in the program, they must be re-compiled when these strings are changed, such as the database driver, URL, user name, and password information when writing the database
Java.util
Class Resourcebundle.control
Java.lang.Object
Java.util.ResourceBundle.Control
Enclosing class:
ResourceBundle
The public static class Resourcebundle.control extends Objectresourcebundle.control defines a set of callback
Properties and ResourceBundle, bundle. properties of attribute File Operations1. Properties and ResourceBundle
Both classes can read key-value pairs stored in the property file in the form of key/value. ResourceBundle is relatively simple to read
Javaweb Internationalization
DateFormat: A tool class that formats dates and is itself an abstract class;
NumberFormat: the character class that formats numbers into numeric strings, or currency strings;
Messageformat: You can format pattern
DateFormat: A tool class that formats a date, itself an abstract class;NumberFormat: A character class that formats numeric to numeric strings, or currency strings;Messageformat: Can format pattern string, pattern string: string with placeholder:
Today in the development, need to put some information into the configuration file, easy to follow the changes, note that the use of ResourceBundle read configuration file, remember before also saw the use of properties, it is more curious about the
http://www.verejava.com/?id=16994867037422/** Java.util.ResourceBundle: The contents of the Class (*.properties) resource file used to read the resource file are key=value key-value pairs Note: 1. When reading a resource file based on locale, if A
The first approachInputStream is = Test.class.getResourceAsStream ("dbconfig.properties");Properties P = new properties ();P.load (IS);System.out.println (P.get ("Jndi"));Test.class to be placed in the same directory as the Dbconfig.properties???
ResourceBundle is used to read the properties configuration file, the location of the configuration file can only be placed in the SRC root directory, of course, the purpose of this function is to achieve internationalization.The code is as follows:
ResourceBundle read the file is under the Classpath path, that is, src or src directory, and we need to package in the project, packaged properties file in the jar, modification is very inconvenient, We need to place the properties file outside the
Environment:Idea 2018.1.3 Community Edition, jdk8,spring4.2.0,maven3.5.2Theme:Spring InternationalizationProblems that arise:ResourceBundle [message] not found for Messagesource:can ' t find bundle for Base name message, Local_zhSolve:Reference
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.