本文整理匯總了Java中java.util.prefs.Preferences.clear方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.clear方法的具體用法?Java Preferences.clear怎麽用?Java Preferences.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.clear方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: save
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void save() throws IOException {
try {
Preferences prefs = NbPreferences.forModule(FilterRepository.class);
prefs = prefs.node("Filters"); //NOI18N
prefs.clear();
prefs.putBoolean("firstTimeStart", false); //NOI18N
prefs.putBoolean("firstTimeStartWithIssue", false); //NOI18N
prefs.putInt("count", filters.size()); //NOI18N
prefs.putInt("active", active); //NOI18N
for (int i = 0; i < filters.size(); i++) {
NotificationFilter filter = filters.get(i);
filter.save(prefs, "Filter_" + i); //NOI18N
}
} catch (BackingStoreException bsE) {
throw new IOException("Cannot save filter repository", bsE);
}
}
示例2: save
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void save() throws IOException {
try {
Preferences prefs = NbPreferences.forModule( FilterRepository.class );
prefs = prefs.node( "Filters" ); //NOI18N
prefs.clear();
prefs.putBoolean( "firstTimeStart", false ); //NOI18N
prefs.putBoolean( "firstTimeStartWithIssue", false ); //NOI18N
prefs.putInt( "count", filters.size() ); //NOI18N
prefs.putInt( "active", active ); //NOI18N
for( int i=0; i<filters.size(); i++ ) {
TaskFilter filter = filters.get( i );
filter.save( prefs, "Filter_" + i ); //NOI18N
}
} catch( BackingStoreException bsE ) {
IOException ioE = new IOException( "Cannot save filter repository" ); //NOI18N
ioE.initCause( bsE );
throw ioE;
}
}
示例3: storeUpdateElements
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static void storeUpdateElements (OperationType operationType, Collection<UpdateElement> elements) {
Preferences p = getPreferences (operationType);
try {
if (p.keys ().length > 0) {
p.clear ();
}
} catch (BackingStoreException ex) {
Logger.getLogger (LazyInstallUnitWizardIterator.class.getName ()).log (Level.WARNING, ex.getLocalizedMessage (), ex);
}
if (elements == null) {
return ;
}
for (UpdateElement el : elements) {
p.put (el.getCodeName (), toString (el));
}
}
示例4: storeLazyUnits
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static void storeLazyUnits (OperationType operationType, Collection<LazyUnit> units) {
Preferences p = getPreferences (operationType);
try {
if (p.keys ().length > 0) {
p.clear ();
}
} catch (BackingStoreException ex) {
Logger.getLogger (LazyInstallUnitWizardIterator.class.getName ()).log (Level.WARNING, ex.getLocalizedMessage (), ex);
}
if (units == null) {
return ;
}
for (LazyUnit u : units) {
p.put (u.getCodeName (), u.toString ());
}
}
示例5: promptToDelete
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private boolean promptToDelete(Preferences prefs) {
Object result = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.msg_clear_keys"),
NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.title_clear_keys"),
NotifyDescriptor.OK_CANCEL_OPTION));
if (result == NotifyDescriptor.OK_OPTION) {
try {
LOG.log(Level.FINE, "agreed to delete stored passwords: {0}", Arrays.asList(prefs.keys()));
prefs.clear();
return testSampleKey(prefs);
} catch (BackingStoreException x) {
LOG.log(Level.INFO, null, x);
}
} else {
LOG.fine("refused to delete stored passwords");
}
return false;
}
示例6: storeFileNames
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void storeFileNames() {
Preferences p = Preferences.userNodeForPackage(this.getClass());
try {
p.clear();
p.flush();
p = Preferences.userNodeForPackage(this.getClass());
int itemCount = projectInfotable.getItems().size();
int selected = projectInfotable.getSelectionModel().getSelectedIndex();
if (selected == -1)
selected = 0;
ProjectInfo pi = projectInfotable.getItems().get(selected);
p.put("dirName0", pi.getFolder());
for (int i = 0, j = 1; i < itemCount; i++) {
if (i != selected) {
p.put("dirName" + j++, projectInfotable.getItems().get(i).getFolder());
}
}
} catch (BackingStoreException e) {
return;
}
}
示例7: getPrefs
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static Preferences getPrefs(boolean shouldClear) {
if (prefs == null) {
synchronized (AppPreferences.class) {
if (prefs == null) {
Preferences p = Preferences.userNodeForPackage(Main.class);
if (shouldClear) {
try {
p.clear();
} catch (BackingStoreException e) {
}
}
myListener = new MyListener();
p.addPreferenceChangeListener(myListener);
prefs = p;
setTemplateFile(convertFile(p.get(TEMPLATE_FILE, null)));
setTemplateType(p.getInt(TEMPLATE_TYPE, TEMPLATE_PLAIN));
}
}
}
return prefs;
}
示例8: saveList
import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static void saveList(Preferences parent, List<?> list) throws BackingStoreException {
parent.clear();
for (int i = 0; i < list.size(); i++) {
parent.put(Integer.toString(i), list.get(i).toString());
}
}
示例9: testClear
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testClear() throws Exception {
testKeys();
Preferences pref = getPreferencesNode();
pref.clear();
assertEquals(0,pref.keys().length);
assertNull(pref.get("key1", null));
assertNull(pref.get("key2", null));
}
示例10: dontRemind
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void dontRemind () {
Preferences p = NbPreferences.forModule (Installer.class);
try {
p.clear ();
} catch (BackingStoreException ex) {
Exceptions.printStackTrace (ex);
}
}
示例11: clear
import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static void clear() {
Preferences p = getPrefs(true);
try {
p.clear();
} catch (BackingStoreException e) {
}
}