14.07.2013 Views

Contents - Cultural View

Contents - Cultural View

Contents - Cultural View

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

.properties 22<br />

.properties<br />

Filename<br />

extension<br />

Type of format ASCII<br />

.properties<br />

.properties is a file extension for files mainly used in Java related technologies to store the configurable parameters<br />

of an application. They can also be used for storing strings for Internationalization and localization; these are known<br />

as Property Resource Bundles.<br />

Each parameter is stored as a pair of strings, one storing the name of the parameter (called the key), and the other<br />

storing the value.<br />

Format<br />

Each line in a .properties file normally stores a single property. Several formats are possible for each line, including<br />

key=value, key = value, key:value, and key value.<br />

.properties files can use the number sign (#) or the exclamation mark (!) as the first non blank character in a line to<br />

denote that all text following it is a comment. The backwards slash is used to escape a character. An example of a<br />

properties file is provided below.<br />

# You are reading the ".properties" entry.<br />

! The exclamation mark can also mark text as comments.<br />

website = http://en.wikipedia.org/<br />

language = English<br />

# The backslash below tells the application to continue reading<br />

# the value onto the next line.<br />

message = Welcome to \<br />

Wikipedia!<br />

# Add spaces to the key<br />

key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".<br />

# Unicode<br />

tab : \u0009<br />

In the example above, website would be a key, and its corresponding value would be<br />

http://en.wikipedia.org/. While the number sign and the exclamation mark marks text as comments, it<br />

has no effect when it is part of a property. Thus, the key message has the value Welcome to Wikipedia!<br />

and not Welcome to Wikipedia. Note also that all of the whitespace in front of Wikipedia! is excluded<br />

completely.<br />

The encoding of a .properties file is ISO-8859-1, also known as Latin-1. All non-Latin-1 characters must be entered<br />

by using Unicode escape characters, e. g. \uHHHH where HHHH is a hexadecimal index of the character in the<br />

Unicode character set. This allows for using .properties files as resource bundles for localization. A non-Latin-1 text<br />

file can be converted to a correct .properties file by using the native2ascii tool that is shipped with the JDK or by<br />

using a tool, such as po2prop [1] , that manages the transformation from a bilingual localization format into .properties<br />

escaping.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!