Skip to content

Commit 18c0c4d

Browse files
committed
1
1 parent faa7e78 commit 18c0c4d

21 files changed

+216
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ResourceBundleDemo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.ResourceBundle;
2+
3+
public class ResourceBundleDemo
4+
{
5+
6+
public static void main(String[] args)
7+
{
8+
9+
ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle");
10+
11+
/*
12+
* Determines whether the given key is contained in this
13+
* ResourceBundle or its parent bundles.
14+
*
15+
* Parameters:
16+
*
17+
* key - the resource key
18+
*
19+
* Returns:
20+
*
21+
* true if the given key is contained in this ResourceBundle
22+
* or its parent bundles; false otherwise.
23+
*
24+
*/
25+
boolean result = bundle.containsKey("greeting_lll");
26+
System.out.println(result);
27+
28+
}
29+
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ResourceBundleDemo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.util.Enumeration;
2+
import java.util.ResourceBundle;
3+
4+
public class ResourceBundleDemo
5+
{
6+
7+
public static void main(String[] args)
8+
{
9+
10+
ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle");
11+
12+
/*
13+
* Returns an enumeration of the keys.
14+
*
15+
* Returns:
16+
*
17+
* an Enumeration of the keys contained in this ResourceBundle
18+
* and its parent bundles.
19+
*/
20+
Enumeration<String> enumerationOfKeys = bundle.getKeys();
21+
22+
/*
23+
* Print all the keys and corresponding values
24+
*/
25+
while (enumerationOfKeys.hasMoreElements())
26+
{
27+
String key = enumerationOfKeys.nextElement();
28+
String value = bundle.getString(key);
29+
System.out.println(key+" = "+value);
30+
}
31+
32+
}
33+
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>ResourceBundleDemo</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
greeting=Hello, how are you?
2+
welcome=Welcome to India
3+
meeting=Meeting with Peter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.util.ResourceBundle;
2+
import java.util.Set;
3+
4+
public class ResourceBundleDemo
5+
{
6+
7+
public static void main(String[] args)
8+
{
9+
10+
ResourceBundle bundle = ResourceBundle.getBundle("MessageBundle");
11+
12+
/*
13+
* Returns a Set of all keys contained in this ResourceBundle
14+
* and its parent bundles.
15+
*
16+
* Returns:
17+
*
18+
* a Set of all keys contained in this ResourceBundle and its
19+
* parent bundles.
20+
*
21+
*/
22+
Set<String> keySet = bundle.keySet();
23+
24+
for (String key : keySet)
25+
{
26+
String value = bundle.getString(key);
27+
System.out.println(key + " = " + value);
28+
}
29+
30+
}
31+
32+
}

0 commit comments

Comments
 (0)