当前位置: 首页>>代码示例>>Java>>正文


Java AtomicFile类代码示例

本文整理汇总了Java中com.lody.virtual.helper.utils.AtomicFile的典型用法代码示例。如果您正苦于以下问题:Java AtomicFile类的具体用法?Java AtomicFile怎么用?Java AtomicFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AtomicFile类属于com.lody.virtual.helper.utils包,在下文中一共展示了AtomicFile类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeUserLocked

import com.lody.virtual.helper.utils.AtomicFile; //导入依赖的package包/类
private void writeUserLocked(VUserInfo userInfo) {
    FileOutputStream fos = null;
    AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
    try {
        fos = userFile.startWrite();
        final BufferedOutputStream bos = new BufferedOutputStream(fos);

        // XmlSerializer serializer = XmlUtils.serializerInstance();
        final XmlSerializer serializer = new FastXmlSerializer();
        serializer.setOutput(bos, "utf-8");
        serializer.startDocument(null, true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

        serializer.startTag(null, TAG_USER);
        serializer.attribute(null, ATTR_ID, Integer.toString(userInfo.id));
        serializer.attribute(null, ATTR_SERIAL_NO, Integer.toString(userInfo.serialNumber));
        serializer.attribute(null, ATTR_FLAGS, Integer.toString(userInfo.flags));
        serializer.attribute(null, ATTR_CREATION_TIME, Long.toString(userInfo.creationTime));
        serializer.attribute(null, ATTR_LAST_LOGGED_IN_TIME,
                Long.toString(userInfo.lastLoggedInTime));
        if (userInfo.iconPath != null) {
            serializer.attribute(null,  ATTR_ICON_PATH, userInfo.iconPath);
        }
        if (userInfo.partial) {
            serializer.attribute(null, ATTR_PARTIAL, "true");
        }

        serializer.startTag(null, TAG_NAME);
        serializer.text(userInfo.name);
        serializer.endTag(null, TAG_NAME);

        serializer.endTag(null, TAG_USER);

        serializer.endDocument();
        userFile.finishWrite(fos);
    } catch (Exception ioe) {
        VLog.e(LOG_TAG, "Error writing user info " + userInfo.id + "\n" + ioe);
        userFile.failWrite(fos);
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:41,代码来源:VUserManagerService.java

示例2: writeUserListLocked

import com.lody.virtual.helper.utils.AtomicFile; //导入依赖的package包/类
private void writeUserListLocked() {
    FileOutputStream fos = null;
    AtomicFile userListFile = new AtomicFile(mUserListFile);
    try {
        fos = userListFile.startWrite();
        final BufferedOutputStream bos = new BufferedOutputStream(fos);

        // XmlSerializer serializer = XmlUtils.serializerInstance();
        final XmlSerializer serializer = new FastXmlSerializer();
        serializer.setOutput(bos, "utf-8");
        serializer.startDocument(null, true);
        serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

        serializer.startTag(null, TAG_USERS);
        serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
        serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion));

        for (int i = 0; i < mUsers.size(); i++) {
            VUserInfo user = mUsers.valueAt(i);
            serializer.startTag(null, TAG_USER);
            serializer.attribute(null, ATTR_ID, Integer.toString(user.id));
            serializer.endTag(null, TAG_USER);
        }

        serializer.endTag(null, TAG_USERS);

        serializer.endDocument();
        userListFile.finishWrite(fos);
    } catch (Exception e) {
        userListFile.failWrite(fos);
        VLog.e(LOG_TAG, "Error writing user list");
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:34,代码来源:VUserManagerService.java

示例3: removeUserStateLocked

import com.lody.virtual.helper.utils.AtomicFile; //导入依赖的package包/类
private void removeUserStateLocked(int userHandle) {
    // Cleanup package manager settings
    mPm.cleanUpUser(userHandle);

    // Remove this user from the list
    mUsers.remove(userHandle);
    mRemovingUserIds.remove(userHandle);
    // Remove user file
    AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + ".xml"));
    userFile.delete();
    // Update the user list
    writeUserListLocked();
    updateUserIdsLocked();
    removeDirectoryRecursive(VEnvironment.getUserSystemDirectory(userHandle));
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:16,代码来源:VUserManagerService.java

示例4: removeUserStateLocked

import com.lody.virtual.helper.utils.AtomicFile; //导入依赖的package包/类
private void removeUserStateLocked(int userHandle) {
    // Cleanup package manager settings
    mPm.cleanUpUserLILPw(userHandle);

    // Remove this user from the list
    mUsers.remove(userHandle);
    mRemovingUserIds.remove(userHandle);
    // Remove user file
    AtomicFile userFile = new AtomicFile(new File(mUsersDir, userHandle + ".xml"));
    userFile.delete();
    // Update the user list
    writeUserListLocked();
    updateUserIdsLocked();
    removeDirectoryRecursive(VEnvironment.getUserSystemDirectory(userHandle));
}
 
开发者ID:codehz,项目名称:container,代码行数:16,代码来源:VUserManagerService.java


注:本文中的com.lody.virtual.helper.utils.AtomicFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。