blob: 1b8f0e6b742436436c9a82b839c38f00371f113d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 */
23
24/*
25 *
26 *
27 * This class is used by test i18nTest.sh
28 *
29 * Class to create various i18n Hello World Java source files using
30 * the platform's default encoding of a non-ASCII name; create plain
31 * ASCII Hello World if the platform's default is charset is US-ASCII.
32 */
33
34import java.io.PrintWriter;
35import java.io.FileOutputStream;
36
37public class CreatePlatformFile {
38 public static void main(String argv[]) {
39 String fileSep = System.getProperty("file.separator");
40 String defaultEncoding = System.getProperty("file.encoding");
41
42 if(defaultEncoding == null) {
43 System.err.println("Default encoding not found; Error.");
44 return;
45 }
46
47 if (defaultEncoding.equals("Cp1252") ) {
48 // "HelloWorld" with an accented e
49 String fileName = "i18nH\u00e9lloWorld.java";
50 try {
51 PrintWriter pw = new PrintWriter(new FileOutputStream("."+fileSep+fileName));
52 pw.println("public class i18nH\u00e9lloWorld {");
53 pw.println(" public static void main(String [] argv) {");
54 pw.println(" System.out.println(\"Hello Cp1252 World\");");
55 pw.println(" }");
56 pw.println("}");
57 pw.flush();
58 pw.close();
59 }
60 catch (java.io.FileNotFoundException e) {
61 System.err.println("Problem opening file; test fails");
62 }
63
64 } else {
65 // ASCII "HelloWorld"
66 String fileName = "i18nHelloWorld.java";
67 try {
68 PrintWriter pw = new PrintWriter(new FileOutputStream("."+fileSep+fileName));
69 pw.println("public class i18nHelloWorld {");
70 pw.println(" public static void main(String [] argv) {");
71 pw.println(" System.out.println(\"Warning: US-ASCII assumed; filenames with\");");
72 pw.println(" System.out.println(\"non-ASCII characters will not be tested\");");
73 pw.println(" }");
74 pw.println("}");
75 pw.flush();
76 pw.close();
77 }
78 catch (java.io.FileNotFoundException e) {
79 System.err.println("Problem opening file; test fails");
80 }
81 }
82 }
83}