Makefile.in: Rebuilt.
* Makefile.in: Rebuilt. * Makefile.am (ordinary_java_source_files): Add gnu/gcj/io/DefaultMimeTypes.java and gnu/gcj/io/MimeTypes.java * scripts/MakeDefaultMimeTypes.java: New file. * scripts/mime.types: New file. * scripts/classes.pl: Moved from top level. * classes.pl: Moved to scripts directory. * java/net/URLConnection.java: Implement guessContentTypeFromName. * gnu/gcj/io/MimeTypes.java: New file. * gnu/gcj/io/DefaultMimeTypes.java: New file. From-SVN: r32086
This commit is contained in:
parent
38b3a2c089
commit
06440a12a2
8 changed files with 639 additions and 54 deletions
93
libjava/scripts/MakeDefaultMimeTypes.java
Normal file
93
libjava/scripts/MakeDefaultMimeTypes.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
/* Copyright (C) 2000 Red Hat, Inc.
|
||||
|
||||
This file is part of libgcj.
|
||||
|
||||
This software is copyrighted work licensed under the terms of the
|
||||
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
||||
details. */
|
||||
|
||||
import gnu.gcj.io.MimeTypes;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class MakeDefaultMimeTypes
|
||||
{
|
||||
private static void fatal (String message)
|
||||
{
|
||||
System.err.println ("MakeDefaultMimeTypes Error: " + message);
|
||||
System.exit (-1);
|
||||
}
|
||||
|
||||
public static void main (String[] args)
|
||||
{
|
||||
Hashtable mime_table = new Hashtable ();
|
||||
|
||||
if (args.length != 1)
|
||||
fatal ("missing mime type filename");
|
||||
|
||||
try {
|
||||
MimeTypes.fillFromFile (mime_table, args[0]);
|
||||
} catch (FileNotFoundException ex) {
|
||||
fatal ("can't open " + args[0]);
|
||||
} catch (IOException ex) {
|
||||
fatal ("error reading " + args[0]);
|
||||
}
|
||||
|
||||
System.out.println ("// Do not edit this file! Create a new version with MakeDefaultMimeTypes.\
|
||||
\
|
||||
/* Copyright (C) 2000 Red Hat, Inc.\
|
||||
\
|
||||
This file is part of libgcj.\
|
||||
\
|
||||
This software is copyrighted work licensed under the terms of the\
|
||||
Libgcj License. Please consult the file \"LIBGCJ_LICENSE\" for\
|
||||
details. */\
|
||||
\
|
||||
package gnu.gcj.io; \
|
||||
\
|
||||
public class DefaultMimeTypes\
|
||||
{\
|
||||
public static final String[] types = {");
|
||||
|
||||
Enumeration keys = mime_table.keys();
|
||||
Enumeration values = mime_table.elements();
|
||||
|
||||
// Prepend first element with open bracket
|
||||
StringBuffer result = new StringBuffer("");
|
||||
|
||||
try
|
||||
{
|
||||
result.append(" \""
|
||||
+ keys.nextElement().toString()
|
||||
+ "\",\t\""
|
||||
+ values.nextElement().toString()
|
||||
+ "\"\n");
|
||||
}
|
||||
catch (NoSuchElementException ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Prepend subsequent elements with ", "
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
result.append(" , \""
|
||||
+ keys.nextElement().toString()
|
||||
+ "\",\t\""
|
||||
+ values.nextElement().toString()
|
||||
+ "\"\n");
|
||||
}
|
||||
catch (NoSuchElementException ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Append last element with closing bracket
|
||||
result.append(" };\
|
||||
}\
|
||||
");
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue