@@ -0,0 +1,2904 @@
+package seedu.address.logic.commands;%0A%0A%0Aimport java.io.File;%0A%0A%0Aimport seedu.address.commons.core.EventsCenter;%0Aimport seedu.address.commons.events.model.TaskListChangedEvent;%0Aimport seedu.address.commons.events.storage.FileLocationChangedEvent;%0A%0A%0A/**%0A *%0A * Save the address book data%0A *%0A */%0A%0Apublic class SaveCommand extends Command %7B%0A    public static final String COMMAND_WORD = %22Save%22;%0A    public static final String MESSAGE_USAGE = COMMAND_WORD + %22the path that you wish to save the file to%22%0A                                               + %22Example: %22 + COMMAND_WORD + %22data/chosenFile.xml%22;%0A    public static final String MESSAGE_SUCCESS = %22Task list has been saved!%22;%0A    public static final String MESSAGE_FILE_EXISTS = %22File already exists%22;%0A    public static final String MESSAGE_WRONG_EXTENSION = %22Wrong extension. File must be .xml%22;%0A    public static final String MESSAGE_NO_PERMISSION = %22Do not have the permission to access the file path %22%0A                                                     + %22chosen.%22;%0A%0A    private String filePath;%0A%0A    public SaveCommand(String filePath) %7B%0A        this.filePath = filePath;%0A    %7D%0A%0A    @Override%0A    public CommandResult execute() %7B%0A        String message;%0A        if (!isXMLExtension(filePath)) %7B%0A            return new CommandResult(MESSAGE_WRONG_EXTENSION);%0A        %7D else %7B%0A            if (doesFileExists(filePath)) %7B%0A                return new CommandResult(MESSAGE_FILE_EXISTS);%0A            %7D else %7B%0A                if (canAssessFile(filePath)) %7B%0A                    message = String.format(MESSAGE_SUCCESS, filePath);%0A                %7D else return new CommandResult(MESSAGE_NO_PERMISSION);%0A            %7D%0A        %7D%0A%0A        EventsCenter.getInstance().post(new FileLocationChangedEvent(filePath));%0A        EventsCenter.getInstance().post(new TaskListChangedEvent(model.getTaskList()));%0A        return new CommandResult(message);%0A    %7D%0A%0A    /*%0A     * Check whether the file is .xml extension%0A     * @para filePath will be checked%0A     * @return true if it has%0A     */%0A%0A    private boolean isXMLExtension(String filepath) %7B%0A        if (filepath.equals(%22%22)) %7B%0A            return false;%0A        %7D else %7B%0A            return filePath.endsWith(%22.xml%22);%0A        %7D%0A    %7D%0A%0A    /*%0A     * Check whether the file exists already%0A     * @para filePath will be checked%0A     * @return true if file path given already exists%0A     */%0A%0A    private boolean doesFileExists(String filePath) %7B%0A        File newfile = new File(filePath);%0A        return newfile.exists();%0A    %7D%0A%0A    /*%0A     * Check whether can write to file or not%0A     * @para filePath will be checked%0A     * @return true if file path give can be assessed%0A     */%0A%0A    private boolean canAssessFile(String filePath) %7B%0A        try %7B%0A            File file = new File(filePath).getParentFile();%0A            return file.canWrite();%0A        %7D catch (Exception e) %7B%0A            return false;%0A        %7D%0A    %7D%0A%7D%0A

Update SaveCommand