本文整理汇总了Java中com.trollworks.toolkit.io.SafeFileUpdater.abort方法的典型用法代码示例。如果您正苦于以下问题:Java SafeFileUpdater.abort方法的具体用法?Java SafeFileUpdater.abort怎么用?Java SafeFileUpdater.abort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.trollworks.toolkit.io.SafeFileUpdater
的用法示例。
在下文中一共展示了SafeFileUpdater.abort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.trollworks.toolkit.io.SafeFileUpdater; //导入方法依赖的package包/类
/**
* Saves the data out to the specified file. Does not affect the result of {@link #getFile()}.
*
* @param file The file to write to.
* @return <code>true</code> on success.
*/
public boolean save(File file) {
SafeFileUpdater transaction = new SafeFileUpdater();
boolean success = false;
transaction.begin();
try {
File transactionFile = transaction.getTransactionFile(file);
try (XMLWriter out = new XMLWriter(new BufferedOutputStream(new FileOutputStream(transactionFile)))) {
out.writeHeader();
save(out, true, false);
success = !out.checkError();
}
if (success) {
success = false;
transaction.commit();
setModified(false);
success = true;
} else {
transaction.abort();
}
} catch (Exception exception) {
Log.error(exception);
transaction.abort();
}
return success;
}
示例2: save
import com.trollworks.toolkit.io.SafeFileUpdater; //导入方法依赖的package包/类
/**
* Saves the preference information to disk.
*
* @return Whether the save was successful or not.
*/
public boolean save() {
if (mDirty) {
try {
SafeFileUpdater trans = new SafeFileUpdater();
trans.begin();
try {
File file = trans.getTransactionFile(mFile);
try (OutputStream out = new FileOutputStream(file)) {
mPrefs.storeToXML(out, BundleInfo.getDefault().getName());
}
} catch (IOException ioe) {
trans.abort();
throw ioe;
}
trans.commit();
mDirty = false;
} catch (Exception exception) {
return false;
}
}
return true;
}