|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.github.fge.msgsimple.source.PropertiesMessageSource
public final class PropertiesMessageSource
A message source built from a properties files
You can load property files from the classpath or from files on your filesystem. You can also specify the character set used to read the file; methods without a character set as an argument use UTF-8.
Properties.load(Reader)
Method Summary | |
---|---|
static MessageSource |
fromFile(File file)
Create a message source from a properties file on the filesystem using UTF-8 |
static MessageSource |
fromFile(File file,
Charset charset)
Create a message source from a properties file on the filesystem using the specified charset |
static MessageSource |
fromPath(String path)
Create a message source from a properties file on the filesystem using the specified encoding |
static MessageSource |
fromPath(String path,
Charset charset)
Create a message source from a properties file on the filesystem using the specified charset |
static MessageSource |
fromResource(String resourcePath)
Create a message source from a classpath resource using UTF-8 |
static MessageSource |
fromResource(String resourcePath,
Charset charset)
Create a message source from a classpath resource using the specified charset |
String |
getKey(String key)
Return a message matching a given key |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static MessageSource fromResource(String resourcePath) throws IOException
resourcePath
- the path to the properties file
NullPointerException
- resource path is null
IOException
- no such resource, or an I/O error occurred while
reading the filepublic static MessageSource fromResource(String resourcePath, Charset charset) throws IOException
resourcePath
- the path to the properties filecharset
- the character set to use
NullPointerException
- resource path is null
IOException
- no such resource, or an I/O error occurred while
reading the filepublic static MessageSource fromFile(File file) throws IOException
file
- the file to read from
NullPointerException
- file is null
FileNotFoundException
- file does not exist, or cannot access file
IOException
- failed to read from filepublic static MessageSource fromPath(String path) throws IOException
This essentially calls fromFile(File)
.
path
- the file path
NullPointerException
- path is null
IOException
- see fromFile(File)
public static MessageSource fromFile(File file, Charset charset) throws IOException
file
- the file to read fromcharset
- the character set to use
NullPointerException
- file is null
FileNotFoundException
- file does not exist, or cannot access file
IOException
- failed to read from filepublic static MessageSource fromPath(String path, Charset charset) throws IOException
This essentially calls fromFile(File, Charset)
.
path
- the file pathcharset
- the character set
NullPointerException
- path is null
IOException
- see fromFile(File)
public String getKey(String key)
MessageSource
Note that this method MUST return null
if there is no match
for the given key.
Note also that it is guaranteed that you will never get a null key.
getKey
in interface MessageSource
key
- the key
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |