1 /* Copyright (C) 2000, 2003 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
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
);
24 public static void main (String
[] args
)
26 Hashtable mime_table
= new Hashtable ();
29 fatal ("missing mime type filename");
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.\n\n/* Copyright (C) 2000 Free Software Foundation\n\n This file is part of libgcj.\n\nThis software is copyrighted work licensed under the terms of the\nLibgcj License. Please consult the file \"LIBGCJ_LICENSE\" for\ndetails. */\n\npackage gnu.gcj.io; \n\npublic class DefaultMimeTypes\n{\n public static final String[] types = {");
41 Enumeration keys
= mime_table
.keys();
42 Enumeration values
= mime_table
.elements();
44 // Prepend first element with open bracket
45 StringBuffer result
= new StringBuffer("");
50 + keys
.nextElement().toString()
52 + values
.nextElement().toString()
55 catch (NoSuchElementException ex
)
59 // Prepend subsequent elements with ", "
64 + keys
.nextElement().toString()
66 + values
.nextElement().toString()
69 catch (NoSuchElementException ex
)
73 // Append last element with closing bracket
74 result
.append(" };\n}\n");
75 System
.out
.println(result
);