2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / scripts / MakeDefaultMimeTypes.java
blob49b67d675bd653c2d652b5e6cae31d7f34809c0e
1 /* Copyright (C) 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
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;
16 public class MakeDefaultMimeTypes
18 private static void fatal (String message)
20 System.err.println ("MakeDefaultMimeTypes Error: " + message);
21 System.exit (-1);
24 public static void main (String[] args)
26 Hashtable mime_table = new Hashtable ();
28 if (args.length != 1)
29 fatal ("missing mime type filename");
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]);
39 System.out.println ("// Do not edit this file! Create a new version with MakeDefaultMimeTypes.\
41 /* Copyright (C) 2000 Free Software Foundation\
43 This file is part of libgcj.\
45 This software is copyrighted work licensed under the terms of the\
46 Libgcj License. Please consult the file \"LIBGCJ_LICENSE\" for\
47 details. */\
49 package gnu.gcj.io; \
51 public class DefaultMimeTypes\
53 public static final String[] types = {");
55 Enumeration keys = mime_table.keys();
56 Enumeration values = mime_table.elements();
58 // Prepend first element with open bracket
59 StringBuffer result = new StringBuffer("");
61 try
63 result.append(" \""
64 + keys.nextElement().toString()
65 + "\",\t\""
66 + values.nextElement().toString()
67 + "\"\n");
69 catch (NoSuchElementException ex)
73 // Prepend subsequent elements with ", "
74 try
76 while (true)
77 result.append(" , \""
78 + keys.nextElement().toString()
79 + "\",\t\""
80 + values.nextElement().toString()
81 + "\"\n");
83 catch (NoSuchElementException ex)
87 // Append last element with closing bracket
88 result.append(" };\
90 ");
91 System.out.println(result);