Code example for File

Methods: renameTo

0
    public void commit() { 
        if (!mWriting) {
            throw new IllegalStateException("no file to commit");
        } 
        mWriting = false;
        mTemp.renameTo(mReal);
    } 
 
    /** 
     * Roll back changes. 
     */ 
    public void rollback() { 
        if (!mWriting) {
            throw new IllegalStateException("no file to roll back");
        } 
        mWriting = false;
        mTemp.delete();
    } 
}