当前位置: 首页>>代码示例>>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;未经允许,请勿转载。