當前位置: 首頁>>代碼示例>>Java>>正文


Java Preferences.putByteArray方法代碼示例

本文整理匯總了Java中java.util.prefs.Preferences.putByteArray方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.putByteArray方法的具體用法?Java Preferences.putByteArray怎麽用?Java Preferences.putByteArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.prefs.Preferences的用法示例。


在下文中一共展示了Preferences.putByteArray方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: call

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public Void call() throws Exception { // encryption changing
    LOG.fine("encryption changing");
    Map<String,char[]> saved = new HashMap<String,char[]>();
    Preferences prefs = prefs();
    for (String k : prefs.keys()) {
        if (k.endsWith(DESCRIPTION)) {
            continue;
        }
        byte[] ciphertext = prefs.getByteArray(k, null);
        if (ciphertext == null) {
            continue;
        }
        saved.put(k, encryption.decrypt(ciphertext));
    }
    LOG.log(Level.FINE, "reencrypting keys: {0}", saved.keySet());
    encryption.encryptionChanged();
    for (Map.Entry<String,char[]> entry : saved.entrySet()) {
        prefs.putByteArray(entry.getKey(), encryption.encrypt(entry.getValue()));
    }
    LOG.fine("encryption changing finished");
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:FallbackProvider.java

示例2: store

import java.util.prefs.Preferences; //導入方法依賴的package包/類
static void store(List<HistoryItem> history) {
    Preferences _prefs = getPrefs();
    for (int i = 0; i < history.size(); i++) {
        HistoryItem hi = history.get(i);
        if ((hi.id != i) && (hi.id >= history.size())) {
            _prefs.remove(PROP_URL_PREFIX + hi.id);
            _prefs.remove(PROP_ICON_PREFIX + hi.id);
        }
        hi.id = i;
        _prefs.put(PROP_URL_PREFIX + i, hi.getPath());
        if (hi.getIconBytes() == null) {
            _prefs.remove(PROP_ICON_PREFIX + i);
        } else {
            _prefs.putByteArray(PROP_ICON_PREFIX + i, hi.getIconBytes());
        }
    }
    LOG.log(Level.FINE, "Stored");
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:RecentFiles.java

示例3: testBase64

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testBase64() {
    Preferences orig = Preferences.userRoot().node(getName());
    assertNull("Original contains value", orig.get("key-1", null));
    Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
    test.putByteArray("key-1", "however you like it".getBytes());
    assertEquals("Wrong value", "however you like it", new String(test.getByteArray("key-1", null)));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:ProxyPreferencesImplTest.java

示例4: deepCopy

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private static void deepCopy(Preferences from, Preferences to) throws BackingStoreException {
    for(String kid : from.childrenNames()) {
        Preferences fromKid = from.node(kid);
        Preferences toKid = to.node(kid);
        deepCopy(fromKid, toKid);
    }
    for(String key : from.keys()) {
        String value = from.get(key, null);
        if (value == null) continue;

        Class type = guessType(value);
        if (Integer.class == type) {
            to.putInt(key, from.getInt(key, -1));
        } else if (Long.class == type) {
            to.putLong(key, from.getLong(key, -1L));
        } else if (Float.class == type) {
            to.putFloat(key, from.getFloat(key, -1f));
        } else if (Double.class == type) {
            to.putDouble(key, from.getDouble(key, -1D));
        } else if (Boolean.class == type) {
            to.putBoolean(key, from.getBoolean(key, false));
        } else if (String.class == type) {
            to.put(key, value);
        } else /* byte [] */ {
            to.putByteArray(key, from.getByteArray(key, new byte [0]));
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:FormattingCustomizerPanel.java

示例5: testBase64

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testBase64() {
    Preferences orig = Preferences.userRoot().node(getName());
    assertNull("Original contains value", orig.get("key-1", null));
    Preferences test = ProxyPreferences.getProxyPreferences(this, orig);
    test.putByteArray("key-1", "however you like it".getBytes());
    assertEquals("Wrong value", "however you like it", new String(test.getByteArray("key-1", null)));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:ProxyPreferencesTest.java

示例6: _save

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private boolean _save(String key, char[] password, String description) {
    Preferences prefs = prefs();
    try {
        prefs.putByteArray(key, encryption.encrypt(password));
    } catch (Exception x) {
        LOG.log(Level.FINE, "failed to encrypt password for " + key, x);
        return false;
    }
    if (description != null) {
        // Preferences interface gives no access to *.properties comments, so:
        prefs.put(key + DESCRIPTION, description);
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:FallbackProvider.java

示例7: enabled

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public @Override boolean enabled() {
    if (Boolean.getBoolean("netbeans.keyring.no.master")) {
        LOG.fine("master password encryption disabled");
        return false;
    }
    if (GraphicsEnvironment.isHeadless()) {
        LOG.fine("disabling master password encryption in headless mode");
        return false;
    }
    try {
        KEY_FACTORY = SecretKeyFactory.getInstance(ENCRYPTION_ALGORITHM);
        encrypt = Cipher.getInstance(ENCRYPTION_ALGORITHM);
        decrypt = Cipher.getInstance(ENCRYPTION_ALGORITHM);
        Preferences prefs = NbPreferences.forModule(Keyring.class);
        Utils.goMinusR(prefs);
        String saltKey = "salt"; // NOI18N
        byte[] salt = prefs.getByteArray(saltKey, null);
        if (salt == null) {
            salt = new byte[36];
            new SecureRandom().nextBytes(salt);
            prefs.putByteArray(saltKey, salt);
        }
        PARAM_SPEC = new PBEParameterSpec(salt, 20);
        LOG.warning("Falling back to master password encryption; " +
                "add -J-Dorg.netbeans.modules.keyring.level=0 to netbeans.conf to see why native keyrings could not be loaded");
        return true;
    } catch (Exception x) {
        LOG.log(Level.INFO, "Cannot initialize security using " + ENCRYPTION_ALGORITHM, x);
        return false;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:MasterPasswordEncryption.java

示例8: save

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Save these settings.
 */
@FromAnyThread
public synchronized void save() {

    final Preferences prefs = Preferences.userNodeForPackage(Editor.class);
    prefs.putInt(PREF_GRAPHIC_ANISOTROPY, getAnisotropy());
    prefs.putBoolean(PREF_GRAPHIC_FXAA, isFXAA());
    prefs.putBoolean(PREF_GRAPHIC_GAMA_CORRECTION, isGammaCorrection());
    prefs.putBoolean(PREF_GRAPHIC_STOP_RENDER_ON_LOST_FOCUS, isStopRenderOnLostFocus());
    prefs.putBoolean(PREF_GRAPHIC_TONEMAP_FILTER, isToneMapFilter());
    prefs.putInt(PREF_SCREEN_HEIGHT, getScreenHeight());
    prefs.putInt(PREF_SCREEN_WIDTH, getScreenWidth());
    prefs.putBoolean(PREF_SCREEN_MAXIMIZED, isMaximized());
    prefs.putInt(PREF_OTHER_GLOBAL_LEFT_TOOL_WIDTH, getGlobalLeftToolWidth());
    prefs.putBoolean(PREF_OTHER_GLOBAL_LEFT_TOOL_COLLAPSED, isGlobalLeftToolCollapsed());
    prefs.putInt(PREF_OTHER_GLOBAL_BOTTOM_TOOL_WIDTH, getGlobalBottomToolHeight());
    prefs.putBoolean(PREF_OTHER_GLOBAL_BOTTOM_TOOL_COLLAPSED, isGlobalBottomToolCollapsed());
    prefs.putBoolean(PREF_OTHER_ANALYTICS, isAnalytics());
    prefs.putBoolean(PREF_OTHER_NATIVE_FILE_CHOOSER, isNativeFileChooser());
    prefs.putInt(PREF_GRAPHIC_FRAME_RATE, getFrameRate());
    prefs.putInt(PREF_GRAPHIC_CAMERA_ANGLE, getCameraAngle());
    prefs.putBoolean(PREF_EDITING_AUTO_TANGENT_GENERATING, isAutoTangentGenerating());
    prefs.putBoolean(PREF_EDITING_DEFAULT_USE_FLIPPED_TEXTURE, isDefaultUseFlippedTexture());
    prefs.putBoolean(PREF_EDITING_CAMERA_LAMP_ENABLED, isDefaultEditorCameraEnabled());
    prefs.putBoolean(PREF_OTHER_ANALYTICS_QUESTION, isAnalyticsQuestion());
    prefs.putInt(PREF_OTHER_THEME, getTheme().ordinal());
    prefs.putInt(PREF_GRAPHIC_OPEN_GL, getOpenGLVersion().ordinal());

    final Vector3f whitePoint = getToneMapFilterWhitePoint();

    prefs.put(PREF_GRAPHIC_TONEMAP_FILTER_WHITE_POINT, whitePoint.getX() + "," + whitePoint.getY() + "," + whitePoint.getZ());

    if (currentAsset != null && !Files.exists(currentAsset)) {
        currentAsset = null;
    }

    if (librariesPath != null && !Files.exists(librariesPath)) {
        librariesPath = null;
    }

    if (currentAsset != null) {
        prefs.put(PREF_ASSET_CURRENT_ASSET, currentAsset.toUri().toString());
    } else {
        prefs.remove(PREF_ASSET_CURRENT_ASSET);
    }

    if (librariesPath != null) {
        prefs.put(PREF_OTHER_LIBRARIES_FOLDER, librariesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_LIBRARIES_FOLDER);
    }

    if (classesPath != null) {
        prefs.put(PREF_OTHER_CLASSES_FOLDER, classesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_CLASSES_FOLDER);
    }

    if (additionalEnvs != null) {
        prefs.put(PREF_OTHER_ADDITIONAL_ENVS, additionalEnvs.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_ADDITIONAL_ENVS);
    }

    final List<String> lastOpenedAssets = getLastOpenedAssets();

    prefs.putByteArray(PREF_ASSET_LAST_OPENED_ASSETS, EditorUtil.serialize((Serializable) lastOpenedAssets));
    try {
        prefs.flush();
    } catch (final BackingStoreException e) {
        throw new RuntimeException(e);
    }

    System.setProperty("jfx.frame.transfer.camera.angle", String.valueOf(getCameraAngle()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:78,代碼來源:EditorConfig.java


注:本文中的java.util.prefs.Preferences.putByteArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。