src/share/classes/sun/net/www/MimeTable.java
Print this page
*** 220,264 ****
// For backward compatibility -- mailcap format files
// This is not currently used, but may in the future when we add ability
// to read BOTH the properties format and the mailcap format.
protected static String[] mailcapLocations;
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");
! }
}
! 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");
}
-
- 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;
}
parse(entries);
}
--- 220,254 ----
// For backward compatibility -- mailcap format files
// This is not currently used, but may in the future when we add ability
// to read BOTH the properties format and the mailcap format.
protected static String[] mailcapLocations;
+ private static final String DEFAULT_FILE =
+ "/sun/net/www/content-types.properties";
+
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)).exists()) {
! is = new BufferedInputStream(new FileInputStream(file));
! } else {
! if ((is = MimeTable.class.getResourceAsStream(DEFAULT_FILE)) == null) {
! System.err.println("Warning: default mime table not found.");
! return;
}
! is = new BufferedInputStream(is);
}
entries.load(is);
is.close();
! } catch (IOException e) {
! System.err.println("Warning: " + file != null ? file.getPath() : "default"
! + " mime table not found.");
return;
}
parse(entries);
}
*** 378,399 ****
}
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();
while (e.hasMoreElements()) {
MimeEntry entry = e.nextElement();
--- 368,377 ----