use of org.eclipse.core.internal.preferences.SafeFileOutputStream in project che by eclipse.
the class ChePreferences method write.
/*
* Helper method to persist a Properties object to the filesystem. We use this
* helper so we can remove the date/timestamp that Properties#store always
* puts in the file.
*/
protected static void write(Properties properties, String location) throws BackingStoreException {
// create the parent directories if they don't exist
// File parentFile = new File(location);
// if (parentFile == null)
// return;
// parentFile.mkdirs();
OutputStream output = null;
try {
File file = new File(location);
if (!file.exists()) {
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
file.createNewFile();
}
output = new SafeFileOutputStream(file);
//$NON-NLS-1$
output.write(removeTimestampFromTable(properties).getBytes("UTF-8"));
output.flush();
} catch (IOException e) {
// String message = NLS.bind(PrefsMessages.preferences_saveException, location);
ResourcesPlugin.log(new Status(IStatus.ERROR, PrefsMessages.OWNER_NAME, IStatus.ERROR, "preferences_saveException", e));
throw new BackingStoreException("preferences_saveException");
} finally {
if (output != null)
try {
output.close();
} catch (IOException e) {
// ignore
}
}
}
Aggregations