Tabnine Logo
AtomicFile.startWrite
Code IndexAdd Tabnine to your IDE (free)

How to use
startWrite
method
in
com.lody.virtual.helper.utils.AtomicFile

Best Java code snippets using com.lody.virtual.helper.utils.AtomicFile.startWrite (Showing top 6 results out of 315)

origin: android-hacker/VirtualXposed

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");
  }
}
origin: android-hacker/VirtualXposed

AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
try {
  fos = userFile.startWrite();
  final BufferedOutputStream bos = new BufferedOutputStream(fos);
origin: darkskygit/VirtualApp

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");
  }
}
origin: bzsome/VirtualApp-x326

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");
  }
}
origin: darkskygit/VirtualApp

AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
try {
  fos = userFile.startWrite();
  final BufferedOutputStream bos = new BufferedOutputStream(fos);
origin: bzsome/VirtualApp-x326

AtomicFile userFile = new AtomicFile(new File(mUsersDir, userInfo.id + ".xml"));
try {
  fos = userFile.startWrite();
  final BufferedOutputStream bos = new BufferedOutputStream(fos);
com.lody.virtual.helper.utilsAtomicFilestartWrite

Javadoc

Start a new write operation on the file. This returns a FileOutputStream to which you can write the new file data. The existing file is replaced with the new data. You must not directly close the given FileOutputStream; instead call either #finishWrite(FileOutputStream)or #failWrite(FileOutputStream).

Note that if another thread is currently performing a write, this will simply replace whatever that thread is writing with the new file being written by this thread, and when the other thread finishes the write the new write operation will no longer be safe (or will be lost). You must do your own threading protection for access to AtomicFile.

Popular methods of AtomicFile

  • <init>
    Create a new AtomicFile for a file located at the given File path. The secondary backup file will be
  • delete
    Delete the atomic file. This deletes both the base and backup files.
  • failWrite
    Call when you have failed for some reason at writing to the stream returned by #startWrite(). This w
  • finishWrite
    Call when you have successfully finished writing to the stream returned by #startWrite(). This will
  • openRead
    Open the atomic file for reading. If there previously was an incomplete write, this will roll back t
  • sync

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • findViewById (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now