public static File startSystemCaseManager(String package_path,
            String dest_dir) throws BeastException {

        Logger logger = Logger
                .getLogger("CreateSystemCaseManager.startSystemCaseManager");

        File folder = SystemReader.createFolder(package_path, dest_dir);
        File caseManager = new File(folder, "UserStoriesManager.java");
        FileWriter caseManagerWriter;
        try {
            if (!caseManager.exists()) {
                caseManagerWriter = new FileWriter(caseManager);
                caseManagerWriter.write("package " + package_path + ";\n");
                caseManagerWriter.write("\n");
                caseManagerWriter.write("import org.junit.Assert;\n");
                caseManagerWriter.write("import org.junit.Test;\n");
                caseManagerWriter.write("import org.junit.runner.JUnitCore;\n");
                caseManagerWriter.write("import org.junit.runner.Result;\n");
                
                caseManagerWriter.write("\n");
                caseManagerWriter.write("/**\n");
                caseManagerWriter
                        .write(" * Main class to launch all tests in a single run\n");
                caseManagerWriter.write(" *\n");
                caseManagerWriter.write(" * @author es.upm.dit.gsi.beast\n");
                caseManagerWriter.write(" */\n");
                caseManagerWriter.write("public class UserStoriesManager {\n");
                caseManagerWriter.write("\n");
                caseManagerWriter.flush();
                caseManagerWriter.close();
                // logger.info("CaseManager has been created in "+dest_dir+Reader.createFolderPath(package_path));
            } else {
                List<String> lines = new ArrayList<String>();

                // read the file into lines
                BufferedReader r = new BufferedReader(new FileReader(
                        caseManager));
                String in;
                while ((in = r.readLine()) != null) {
                    lines.add(in);
                }
                r.close();

                lines.remove(lines.size() - 1);

                // write it back
                PrintWriter w = new PrintWriter(new FileWriter(caseManager));
                for (String line : lines) {
                    w.println(line);
                }
                w.close();
            }
        } catch (IOException e) {
            logger.severe("ERROR writing Case Manager file");
            throw new BeastException("ERROR writing Case Manager file", e);
        }

        return caseManager;
    }
public static File startSystemCaseManager ( String package_path , String dest_dir ) throws BeastException { Logger logger = Logger . getLogger ( "CreateSystemCaseManager.startSystemCaseManager" ) ; File folder = SystemReader . createFolder ( package_path , dest_dir ) ; File caseManager = new File ( folder , "UserStoriesManager.java" ) ; FileWriter caseManagerWriter ; try { if ( ! caseManager . exists ( ) ) { caseManagerWriter = new FileWriter ( caseManager ) ; caseManagerWriter . write ( "package " + package_path + ";\n" ) ; caseManagerWriter . write ( "\n" ) ; caseManagerWriter . write ( "import org.junit.Assert;\n" ) ; caseManagerWriter . write ( "import org.junit.Test;\n" ) ; caseManagerWriter . write ( "import org.junit.runner.JUnitCore;\n" ) ; caseManagerWriter . write ( "import org.junit.runner.Result;\n" ) ; caseManagerWriter . write ( "\n" ) ; caseManagerWriter . write ( "/**\n" ) ; caseManagerWriter . write ( " * Main class to launch all tests in a single run\n" ) ; caseManagerWriter . write ( " *\n" ) ; caseManagerWriter . write ( " * @author es.upm.dit.gsi.beast\n" ) ; caseManagerWriter . write ( " */\n" ) ; caseManagerWriter . write ( "public class UserStoriesManager {\n" ) ; caseManagerWriter . write ( "\n" ) ; caseManagerWriter . flush ( ) ; caseManagerWriter . close ( ) ; } else { List < String > lines = new ArrayList < String > ( ) ; BufferedReader r = new BufferedReader ( new FileReader ( caseManager ) ) ; String in ; while ( ( in = r . readLine ( ) ) != null ) { lines . add ( in ) ; } r . close ( ) ; lines . remove ( lines . size ( ) - 1 ) ; PrintWriter w = new PrintWriter ( new FileWriter ( caseManager ) ) ; for ( String line : lines ) { w . println ( line ) ; } w . close ( ) ; } } catch ( IOException e ) { logger . severe ( "ERROR writing Case Manager file" ) ; throw new BeastException ( "ERROR writing Case Manager file" , e ) ; } return caseManager ; }
This method creates CaseManager file and writes on it: the package, the
imports, its comments and the class name.

@param package_path
as es.upm.dit...
@param dest_dir
as src/main/java

@return the File with its first part written
@throws BeastException