--- a/jdk/src/share/classes/sun/net/www/MimeTable.java Tue Apr 15 09:23:07 2014 +0200
+++ b/jdk/src/share/classes/sun/net/www/MimeTable.java Tue Apr 15 11:24:42 2014 +0100
@@ -225,39 +225,28 @@
public synchronized void load() {
Properties entries = new Properties();
File file = null;
- try {
- InputStream is;
- // First try to load the user-specific table, if it exists
- String userTablePath =
- System.getProperty("content.types.user.table");
- if (userTablePath != null) {
- file = new File(userTablePath);
- if (!file.exists()) {
- // No user-table, try to load the default built-in table.
- file = new File(System.getProperty("java.home") +
- File.separator +
- "lib" +
- File.separator +
- "content-types.properties");
- }
+ InputStream in;
+
+ // First try to load the user-specific table, if it exists
+ String userTablePath = System.getProperty("content.types.user.table");
+ if (userTablePath != null && (file = new File(userTablePath)).exists()) {
+ try {
+ in = new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ System.err.println("Warning: " + file.getPath()
+ + " mime table not found.");
+ return;
}
- else {
- // No user table, try to load the default built-in table.
- file = new File(System.getProperty("java.home") +
- File.separator +
- "lib" +
- File.separator +
- "content-types.properties");
- }
+ } else {
+ in = MimeTable.class.getResourceAsStream("content-types.properties");
+ if (in == null)
+ throw new InternalError("default mime table not found");
+ }
- is = new BufferedInputStream(new FileInputStream(file));
- entries.load(is);
- is.close();
- }
- catch (IOException e) {
- System.err.println("Warning: default mime table not found: " +
- file.getPath());
- return;
+ try (BufferedInputStream bin = new BufferedInputStream(in)) {
+ entries.load(bin);
+ } catch (IOException e) {
+ System.err.println("Warning: " + e.getMessage());
}
parse(entries);
}
@@ -380,18 +369,6 @@
return MimeEntry.UNKNOWN;
}
- public synchronized boolean save(String filename) {
- if (filename == null) {
- filename = System.getProperty("user.home" +
- File.separator +
- "lib" +
- File.separator +
- "content-types.properties");
- }
-
- return saveAsProperties(new File(filename));
- }
-
public Properties getAsProperties() {
Properties properties = new Properties();
Enumeration<MimeEntry> e = elements();