No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / examples / hello-java / Hello.java
bloba92f18c8a01a66154bd353493cdab4fba393c1ba
1 // Example for use of GNU gettext.
2 // Copyright (C) 2003 Free Software Foundation, Inc.
3 // This file is in the public domain.
4 //
5 // Source code of the Java program.
7 import java.util.*;
8 import java.io.*;
9 import java.text.*;
10 import gnu.gettext.*;
12 public class Hello {
13 public static void main (String[] args) {
14 ResourceBundle catalog = ResourceBundle.getBundle("hello-java");
15 System.out.println(GettextResource.gettext(catalog,"Hello, world!"));
16 System.out.println(
17 MessageFormat.format(
18 GettextResource.gettext(catalog,
19 "This program is running as process number {0}."),
20 new Object[] { getPid() }));
23 /* Return the process ID of the current process. */
24 private static String getPid () {
25 try {
26 String[] args = new String[] { "/bin/sh", "-c", "echo $PPID" };
27 Process p = Runtime.getRuntime().exec(args);
28 InputStream p_out = p.getInputStream();
29 String s = (new BufferedReader(new InputStreamReader(p_out))).readLine();
30 p.destroy();
31 if (s != null)
32 return s;
33 } catch (IOException e) {
34 e.printStackTrace();
36 return "???";