Makefile.in: Rebuilt.
[gcc.git] / libjava / scripts / MakeDefaultMimeTypes.java
1 /* Copyright (C) 2000 Red Hat, Inc.
2
3 This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
8
9 import gnu.gcj.io.MimeTypes;
10 import java.io.IOException;
11 import java.io.FileNotFoundException;
12 import java.util.Hashtable;
13 import java.util.Enumeration;
14 import java.util.NoSuchElementException;
15
16 public class MakeDefaultMimeTypes
17 {
18 private static void fatal (String message)
19 {
20 System.err.println ("MakeDefaultMimeTypes Error: " + message);
21 System.exit (-1);
22 }
23
24 public static void main (String[] args)
25 {
26 Hashtable mime_table = new Hashtable ();
27
28 if (args.length != 1)
29 fatal ("missing mime type filename");
30
31 try {
32 MimeTypes.fillFromFile (mime_table, args[0]);
33 } catch (FileNotFoundException ex) {
34 fatal ("can't open " + args[0]);
35 } catch (IOException ex) {
36 fatal ("error reading " + args[0]);
37 }
38
39 System.out.println ("// Do not edit this file! Create a new version with MakeDefaultMimeTypes.\
40 \
41 /* Copyright (C) 2000 Red Hat, Inc.\
42 \
43 This file is part of libgcj.\
44 \
45 This software is copyrighted work licensed under the terms of the\
46 Libgcj License. Please consult the file \"LIBGCJ_LICENSE\" for\
47 details. */\
48 \
49 package gnu.gcj.io; \
50 \
51 public class DefaultMimeTypes\
52 {\
53 public static final String[] types = {");
54
55 Enumeration keys = mime_table.keys();
56 Enumeration values = mime_table.elements();
57
58 // Prepend first element with open bracket
59 StringBuffer result = new StringBuffer("");
60
61 try
62 {
63 result.append(" \""
64 + keys.nextElement().toString()
65 + "\",\t\""
66 + values.nextElement().toString()
67 + "\"\n");
68 }
69 catch (NoSuchElementException ex)
70 {
71 }
72
73 // Prepend subsequent elements with ", "
74 try
75 {
76 while (true)
77 result.append(" , \""
78 + keys.nextElement().toString()
79 + "\",\t\""
80 + values.nextElement().toString()
81 + "\"\n");
82 }
83 catch (NoSuchElementException ex)
84 {
85 }
86
87 // Append last element with closing bracket
88 result.append(" };\
89 }\
90 ");
91 System.out.println(result);
92 }
93 }