/*
 * The MIT License
 *
 *  Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *  THE SOFTWARE.
 */

package org.easybatch.tutorials.common;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;

import javax.sql.DataSource;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;

import static org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType.HSQL;

/**
 * Utility class for embedded database.
 */
public class DatabaseUtil {

    private static EmbeddedDatabase embeddedDatabase;
    private static JdbcTemplate jdbcTemplate;

    public static DataSource getDataSource() throws SQLException {
        return embeddedDatabase;
    }

    public static void startEmbeddedDatabase() throws Exception {
        System.setProperty("hsqldb.reconfig_logging", "false");
        embeddedDatabase = new EmbeddedDatabaseBuilder()
                .setType(HSQL)
                .addScript("db/schema.sql")
                .addScript("db/data.sql")
                .build();
        jdbcTemplate = new JdbcTemplate(embeddedDatabase);
    }

    public static void deleteAllTweets() {
        jdbcTemplate.update("delete from tweet");
    }

    public static void dumpTweetTable() throws Exception {
        System.out.println("Loading tweets from the database...");
        jdbcTemplate.query("select * from tweet", new RowCallbackHandler() {
            @Override
            public void processRow(ResultSet resultSet) throws SQLException {
                System.out.println(
                        "Tweet : id= " + resultSet.getString("id") + " | " +
                                "user= " + resultSet.getString("user") + " | " +
                                "message= " + resultSet.getString("message")
                );
            }
        });
    }

    public static void cleanUpWorkingDirectory() {
        //delete hsqldb tmp files
        new File("mem.log").delete();
        new File("mem.properties").delete();
        new File("mem.script").delete();
        new File("mem.tmp").delete();
    }

}
@@ -1590,24 +1590,65 @@
 Exception;%0A%0A
+import org.apache.commons.io.FileUtils;%0A%0A
 import stati
@@ -3214,32 +3214,56 @@
 p files%0A        
+FileUtils.deleteQuietly(
 new File(%22mem.lo
@@ -3265,24 +3265,16 @@
 em.log%22)
-.delete(
 );%0A     
@@ -3268,32 +3268,56 @@
 log%22));%0A        
+FileUtils.deleteQuietly(
 new File(%22mem.pr
@@ -3326,24 +3326,16 @@
 erties%22)
-.delete(
 );%0A     
@@ -3329,32 +3329,56 @@
 ies%22));%0A        
+FileUtils.deleteQuietly(
 new File(%22mem.sc
@@ -3383,24 +3383,16 @@
 script%22)
-.delete(
 );%0A     
@@ -3394,16 +3394,40 @@
         
+FileUtils.deleteQuietly(
 new File
@@ -3441,16 +3441,8 @@
 mp%22)
-.delete(
 );%0A 
@@ -3447,9 +3447,10 @@
 %0A    %7D%0A%0A
-
 %7D
+%0A

Use apache commons-io for file operations