Example usage for java.io FileWriter append

List of usage examples for java.io FileWriter append

Introduction

In this page you can find the example usage for java.io FileWriter append.

Prototype

@Override
    public Writer append(CharSequence csq) throws IOException 

Source Link

Usage

From source file:com.google.android.gms.example.bannerexample.CreateFile.java

public void generateNoteOnSD(String sFileName, String sBody) {
    try {/*from   w  w w  . j  a  v  a 2  s.c  o  m*/
        File root = new File(Environment.getExternalStorageDirectory(), "Notes");
        if (!root.exists()) {
            root.mkdirs();
        }
        File gpxfile = new File(root, sFileName);
        FileWriter writer = new FileWriter(gpxfile);
        JSONObject search = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        JSONObject studentsObj = new JSONObject();

        //            ayaNumbers = new Constants(getApplicationContext()).extractNumbers(fileSupHeaders);
        //            Collections.sort(ayaNumbers);
        //          //  Collections.reverse(ayaNumbers);
        //            for (int i = 0; i < ayaNumbers.size(); i++) {
        //                ayaNumbers2.add(ayaNumbers.get(i).toString());
        //            }
        //
        //            Log.d("numbers are", ayaNumbers2.toString());
        //
        //            for (int i = 0; i < ayaNumbers2.size(); i++) {
        //                Log.d("value is", ayaNumbers2.get(i));
        //
        //                for (int j = 0; j < fileSupHeaders.size(); j++) {
        //
        //                    if (fileSupHeaders.get(j).matches(".*\\b" + ayaNumbers2.get(i) + "\\b.*")) {
        //                        Log.d("MATCHER IS", fileSupHeaders.get(j));
        //                        sortedAyat.add(0, fileSupHeaders.get(j));
        //                        Log.d("aya", fileSupHeaders.get(j));
        //                        filesSorted.add(0, dataList3.get(j));
        //                        sortedSor.add(0,fileHeaders.get(j));
        //
        //                    }
        //                }
        //                matcher = false;
        //
        //            }

        for (int i = 0; i < dataList.size(); i++) {
            try {
                search = new JSONObject();
                search.put("aya", fileSupHeaders.get(i));
                search.put("sora", fileHeaders.get(i));
                search.put("filename", dataList3.get(i));
                jsonArray.put(search);

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // writer.append("{"+"\"header1\":" + fileHeaders.get(i) + ","+ "\"header2\":"  + fileSupHeaders.get(i) +","+ "\"header3\":"  + dataList3.get(i) + "} ,");
        }

        try {
            studentsObj.put("data", jsonArray);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        String jsonStr = studentsObj.toString();
        writer.append(jsonStr);

        //            System.out.println("jsonString: "+jsonStr);
        //            writer.append("]}");
        writer.flush();
        writer.close();
        //  Toast.makeText(this, "Saved", Toast.LENGTH_SHORT).show();
    } catch (IOException e) {
        e.printStackTrace();
        //            importError = e.getMessage();
        //            iError();
    }
}

From source file:SimpleGui.QueryGenerator.java

/**
 * The following code will generate code and saves it in a comma separated file (.csv)
 * File contains two columns of values./*w w  w.  j  a  va 2s  .  c  om*/
 * First column: arrival time of the query (as described in the distribution)
 * Second column: query itself
 */
public ArrayList<File> generateQuerySet() throws IOException {
    //1.Decide on number of single sub-queries (upto 5)
    //2. Generate all permutations of sub-queries from 1 to given number (for the given number of
    // sub-queries) into an arraylist
    //3. Generate values with given sub-query distribution
    //4. Pick  a particular sub-query sequence and if it is shorter than the required length, add some
    // arbitrary sub-queries.
    //5. Save in an appropriate file with proper file name

    //=====================================================================
    ArrayList<File> inputFiles = new ArrayList<>();
    File sqFile = null;
    FileWriter sqWriter = null;

    File qFile = null;
    FileWriter qWriter = null;

    // get distributions of user locations
    setUserLocations();

    //generate query set for a specified number of epochs
    for (int epoch = 1; epoch <= this.getNoEpochs(); epoch++) {
        String distribution = this.distributions[epoch - 1];
        int numQs = numbQs[epoch - 1];
        String pcQueryRepeat = percentQueryRepetition[epoch - 1];
        int numSubqs = numbSubQs[epoch - 1];
        String pcSubQRepeat = percentSubqueryRepetition[epoch - 1];
        int u_upper = uniformUpperLimit[epoch - 1];
        int u_lower = uniformLowerLimit[epoch - 1];
        double slope = slopeValue[epoch - 1];

        // get distributions of  arrival times
        int[] arrivalTimes = getDistributionValues(distribution, numQs, meanValues[epoch - 1],
                varianceValues[epoch - 1], meanExponentialValues[epoch - 1], u_lower, u_upper, slope, numQs);
        Arrays.sort(arrivalTimes);

        System.out.println(getUserLocations().size());
        int[] userLocationDetails = getDistributionValues("Uniform", numQs, getUserLocations().size() / 2,
                getUserLocations().size() / 3, 2, 0, getUserLocations().size() - 1, 1,
                getUserLocations().size());

        // The following if condition is to specify whether we would want only sub-query repeatition or only query repetition
        //if we want only sub-query repetition, then query repetition is chose to be "None" and vice versa.
        if (pcQueryRepeat.equals("None")) { //if you want only sub query repetition
            //Following code is to create queries with sub-query repeat
            sqFile = new File("//home//santhilata//Dropbox//CacheLearning//QGen//src//main//java//QueryInput//"
                    + epoch + "_subqueryRepeat_10.csv");

            sqWriter = new FileWriter(sqFile);

            sqWriter.flush();
            //sqWriter.append("Arrival time,Query");
            //sqWriter.append('\n');

            //considering 10 uniq queries at the moment. So variance is not much
            double variance = 0;
            double slopeSubQ = 0;
            if (pcSubQRepeat.equals("Poisson"))
                variance = 3;
            else if (pcSubQRepeat.equals("Grading"))
                slopeSubQ = 1.5;

            createSubQuerySequences(numSubqs); //creates two lists: uniqQs and uniqSubQs
            ArrayList<String> sub_queryList = new ArrayList<>();
            ArrayList<String> inputQueryList = null;

            int[] sampleSQValues = getDistributionValues(pcSubQRepeat, numQs, (double) uniqSubQs.size() / 2.0,
                    variance, (double) uniqSubQs.size() / 3.0, 0, uniqSubQs.size() - 1, slopeSubQ,
                    uniqSubQs.size());

            for (int j = 0; j < numQs; j++) {
                String str = uniqSubQs.get(sampleSQValues[j]);
                String[] numSubQueries = str.split(Pattern.quote(")"));
                int remaining = numSubqs - numSubQueries.length;

                if (remaining > 0) { // if chosen sequences are less than required number of subqueries
                    for (int i = 0; i < remaining; i++) {
                        str = str + uniqSubQs.get(new Random().nextInt(uniqSubQs.size()));
                    }
                }
                sub_queryList.add(str);

            }
            if (numSubqs == 1)
                inputQueryList = getQueryExpression_oneNode(sub_queryList);
            if (numSubqs == 2)
                inputQueryList = getQueryExpression_twoNode(sub_queryList);
            if (numSubqs == 3)
                inputQueryList = getQueryExpression_threeNode(sub_queryList);
            if (numSubqs == 4)
                inputQueryList = getQueryExpression_fourNode(sub_queryList);
            if (numSubqs == 5)
                inputQueryList = getQueryExpression_fiveNode(sub_queryList);

            //now write them back to a file
            for (int queries = 0; queries < numQs; queries++) {

                sqWriter.append(arrivalTimes[queries] + "@"); // add arrival times as the first column
                // File sub_querySamples = new File
                //          ("//home//santhilata//dropbox//CacheLearning//QGen//src//main//java//QueryInput//SubQueries" +
                //                ".txt");
                sqWriter.append(userLocationDetails[queries] + "@");
                sqWriter.append(inputQueryList.get(queries) + "\n");
            }

            sqWriter.close();

        } // if you want only sub query repetition
        else {
            //Following code is to create queries with sub-query repeat
            qFile = new File("//home//santhilata//Dropbox//CacheLearning//QGen//src//main//java//QueryInput//"
                    + epoch + "_queryRepeat_10.csv");
            qWriter = new FileWriter(qFile);

            qWriter.flush();
            //qWriter.append("Arrival time,Query");
            //qWriter.append('\n');

            //considering 10 uniq queries at the moment. So variance is not much
            double variance = 0;
            double slopeQ = 0;

            // if (pcQueryRepeat.equals("Poisson"))  variance = 3; // variance for 20 - 6, 50-12, 100-24
            if (pcQueryRepeat.equals("Grading"))
                slopeQ = 1.5;

            createSubQuerySequences(numSubqs);
            ArrayList<String> queryList1 = null;
            //create unique query lists
            if (numSubqs == 1)
                queryList1 = getQueryExpression_oneNode(uniqQs);
            else if (numSubqs == 2)
                queryList1 = getQueryExpression_twoNode(uniqQs);
            else if (numSubqs == 3)
                queryList1 = getQueryExpression_threeNode(uniqQs);
            else if (numSubqs == 4)
                queryList1 = getQueryExpression_fourNode(uniqQs);
            else if (numSubqs == 5)
                queryList1 = getQueryExpression_fiveNode(uniqQs);

            int[] sampleQValues = getDistributionValues(pcQueryRepeat, numQs, (double) queryList1.size() / 2.0,
                    (double) queryList1.size() / 4.0, (double) queryList1.size() / 3.0, 0,
                    queryList1.size() - 1, slopeQ, queryList1.size());

            for (int i = 0; i < numQs; i++) {
                qWriter.append(arrivalTimes[i] + "@");
                qWriter.append(userLocationDetails[i] + "@");
                qWriter.append(queryList1.get(sampleQValues[i]) + "\n");
            }
            qWriter.close();
        }

        countQueries(epoch); // to count unique queries. This step is for debugging purposes only
        File file;
        if (sqFile != null)
            file = sqFile;
        else
            file = qFile;

        inputFiles.add(file);

    } // for epoch loop
      // generateSubQuerySamples(4000);

    return inputFiles;
}

From source file:TmlCommandLine.java

@SuppressWarnings("rawtypes")
private static void operation() throws ParseException {

    if (line.hasOption("ocorpus") && (line.getOptionValue("ocorpus") == null
            || line.getOptionValue("ocorpus").trim().length() == 0)) {
        throw new ParseException("Invalid ocorpus option argument value.");
    }//from w  ww.j  av  a  2s. com

    String allDocsCorpusType = line.getOptionValue("oalldocs");
    if (line.hasOption("oalldocs") && !allDocsCorpusType.equals("sentence")
            && !allDocsCorpusType.equals("paragraph")) {
        throw new ParseException("Invalid oalldocs option argument value.");
    }

    String[] operations = line.getOptionValues("operations");
    if (operations == null || operations.length == 0) {
        throw new ParseException("You must specify at least one operation!");
    }

    if (!startTML()) {
        throw new ParseException("Fatal error initializing TML.");
    }

    try {
        repository = new Repository(repositoryFolder);
    } catch (Exception e) {
        logger.error(e);
        return;
    }

    String[] corpusQueries = null;
    if (line.hasOption("ocorpus")) {
        corpusQueries = new String[1];
        corpusQueries[0] = line.getOptionValue("ocorpus");
    } else if (line.hasOption("oalldocs")) {
        List<TextDocument> docs = null;
        try {
            docs = repository.getAllTextDocuments();
        } catch (Exception e) {
            logger.fatal("Couldn't get list of documents from repository.");
            throw new ParseException(e.getMessage());
        }
        corpusQueries = new String[docs.size()];
        for (int i = 0; i < docs.size(); i++) {
            TextDocument doc = docs.get(i);
            String referenceId = null;
            if (line.getOptionValue("oalldocs").equals("sentence"))
                referenceId = "p*d" + doc.getExternalId();
            else
                referenceId = doc.getExternalId();
            corpusQueries[i] = "type:" + line.getOptionValue("oalldocs") + " AND reference:" + referenceId;
        }
    }

    String corpusLine = "NoCorpus";
    if (line.hasOption("ocorpus"))
        corpusLine = line.getOptionValue("ocorpus").replaceAll("\\W", "");
    else if (line.hasOption("oalldocs"))
        corpusLine = "AllDocuments";
    String resultsFilename = repository.getIndexPath().substring(1).replaceAll("[/\\\\]", "_") + "."
            + corpusLine + "." + (new SimpleDateFormat("yyyy-MM-dd-hh-mm")).format(new Date()) + ".txt";

    // Initialize arrays and set default parameters
    DimensionalityReduction[] dims = new DimensionalityReduction[1];
    double[] dimths = new double[1];
    boolean lanczos = false;
    TermSelection[] tsels = new TermSelection[1];
    double[] tselths = new double[1];
    LocalWeight[] twlocals = new LocalWeight[1];
    GlobalWeight[] twglobals = new GlobalWeight[1];

    CorpusParameters parameters = new CorpusParameters();
    dims[0] = parameters.getDimensionalityReduction();
    dimths[0] = parameters.getDimensionalityReductionThreshold();
    lanczos = parameters.isLanczosSVD();
    tsels[0] = parameters.getTermSelectionCriterion();
    tselths[0] = parameters.getTermSelectionThreshold();
    twlocals[0] = parameters.getTermWeightLocal();
    twglobals[0] = parameters.getTermWeightGlobal();

    // If the ocpar option is given, load the parameters file and
    // override the default parameters
    if (line.hasOption("ocpar")) {
        parameters.loadFromFile(new File(line.getOptionValue("ocpar")));
        dims[0] = parameters.getDimensionalityReduction();
        dimths[0] = parameters.getDimensionalityReductionThreshold();
        lanczos = parameters.isLanczosSVD();
        tsels[0] = parameters.getTermSelectionCriterion();
        tselths[0] = parameters.getTermSelectionThreshold();
        twlocals[0] = parameters.getTermWeightLocal();
        twglobals[0] = parameters.getTermWeightGlobal();
    } else {
        // Check for every possible parameter
        if (line.hasOption("odim")) {
            dims = new DimensionalityReduction[line.getOptionValues("odim").length];
            for (int i = 0; i < dims.length; i++)
                dims[i] = DimensionalityReduction.valueOf(line.getOptionValues("odim")[i]);
        }
        if (line.hasOption("odimth")) {
            dimths = new double[line.getOptionValues("odimth").length];
            for (int i = 0; i < dimths.length; i++)
                dimths[i] = Double.parseDouble(line.getOptionValues("odimth")[i]);
        }
        if (line.hasOption("olanczos"))
            lanczos = true;
        else
            lanczos = false;
        if (line.hasOption("otsel")) {
            tsels = new TermSelection[line.getOptionValues("otsel").length];
            for (int i = 0; i < tsels.length; i++)
                tsels[i] = TermSelection.valueOf(line.getOptionValues("otsel")[i]);
        }
        if (line.hasOption("otselth")) {
            tselths = new double[line.getOptionValues("otselth").length];
            for (int i = 0; i < tselths.length; i++)
                tselths[i] = Double.parseDouble(line.getOptionValues("otselth")[i]);
        }
        if (line.hasOption("otwl")) {
            twlocals = new LocalWeight[line.getOptionValues("otwl").length];
            for (int i = 0; i < twlocals.length; i++)
                twlocals[i] = LocalWeight.valueOf(line.getOptionValues("otwl")[i]);
        }
        if (line.hasOption("otwg")) {
            twglobals = new GlobalWeight[line.getOptionValues("otwg").length];
            for (int i = 0; i < twglobals.length; i++)
                twglobals[i] = GlobalWeight.valueOf(line.getOptionValues("otwg")[i]);
        }
    }

    String resultsFolder = line.getOptionValue("oresults");
    FileWriter writer = null;
    if (resultsFolder != null) {
        File resultsFold = new File(resultsFolder);
        if (resultsFold.exists() && resultsFold.isDirectory()) {
            try {
                File results = new File(resultsFolder + "/" + resultsFilename);
                writer = new FileWriter(results);
            } catch (IOException e) {
                logger.error(e);
                writer = null;
            }
        }
    }

    // Create the whole combination of parameters
    for (TermSelection tsel : tsels)
        for (double tselth : tselths)
            for (LocalWeight lw : twlocals)
                for (GlobalWeight gw : twglobals) {
                    CorpusParameters p = new CorpusParameters();
                    p.setTermSelectionCriterion(tsel);
                    p.setLanczosSVD(lanczos);
                    p.setTermSelectionCriterion(tsel);
                    p.setTermSelectionThreshold(tselth);
                    p.setTermWeightLocal(lw);
                    p.setTermWeightGlobal(gw);

                    logger.debug("Parameters to execute: " + p.toString());

                    SearchResultsCorpus backgroundKnowledgeCorpus = null;

                    // If we have background knowledge, load it
                    if (line.hasOption("obk")) {
                        backgroundKnowledgeCorpus = new SearchResultsCorpus(line.getOptionValue("obk"));
                        if (line.hasOption("obkpar")) {
                            CorpusParameters bkParameters = new CorpusParameters();
                            bkParameters.loadFromFile(new File(line.getOptionValue("obkpar")));
                            backgroundKnowledgeCorpus.setParameters(bkParameters);
                        }
                        try {
                            backgroundKnowledgeCorpus.load(repository);
                        } catch (Exception e) {
                            logger.error("Couldn't load background knowledge corpus.");
                            logger.error(e);
                            e.printStackTrace();
                            continue;
                        }
                    }

                    // Create the corpus with the query
                    for (String corpusQuery : corpusQueries) {
                        SearchResultsCorpus corpus = new SearchResultsCorpus(corpusQuery);

                        // Loading the corpus
                        try {
                            corpus.setParameters(p);
                            corpus.load(repository);
                        } catch (Exception e) {
                            logger.error("Couldn't load corpus. " + corpus.getLuceneQuery());
                            logger.error(e);
                            continue;
                        }

                        for (DimensionalityReduction dred : dims)
                            for (double dimth : dimths) {
                                p.setDimensionalityReduction(dred);
                                p.setDimensionalityReductionThreshold(dimth);
                                try {
                                    corpus.getParameters().setDimensionalityReduction(dred);
                                    corpus.getParameters().setDimensionalityReductionThreshold(dimth);
                                    if (backgroundKnowledgeCorpus == null)
                                        corpus.getSemanticSpace().calculate();
                                } catch (Exception e) {
                                    logger.error("Couldn't calculate corpus' semantic space");
                                    logger.error(e);
                                    e.printStackTrace();
                                    continue;
                                }
                                for (String operation : operations) {
                                    Class classDefinition = null;
                                    Operation op = null;
                                    try {
                                        classDefinition = Class
                                                .forName("tml.vectorspace.operations." + operation);
                                        op = (Operation) classDefinition.newInstance();
                                    } catch (Exception e) {
                                        logger.error("The operation wasn't found");
                                        e.printStackTrace();
                                        logger.error(e);
                                        continue;
                                    }

                                    op.setCorpus(corpus);
                                    if (backgroundKnowledgeCorpus != null)
                                        op.setBackgroundKnowledgeCorpus(backgroundKnowledgeCorpus);
                                    try {
                                        op.start();
                                    } catch (Exception e) {
                                        logger.error("Error while performing the operation");
                                        e.printStackTrace();
                                        logger.error(e);
                                        continue;
                                    }

                                    String backgroundline = "None";
                                    String parametersline = corpus.getParameters().toString();
                                    if (backgroundKnowledgeCorpus != null) {
                                        backgroundline = backgroundKnowledgeCorpus.getLuceneQuery() + " ["
                                                + backgroundKnowledgeCorpus.getSemanticSpace()
                                                        .getDimensionsKept()
                                                + "]";
                                        parametersline = backgroundKnowledgeCorpus.getParameters().toString();
                                    } else {
                                        backgroundline += " [" + corpus.getSemanticSpace().getDimensionsKept()
                                                + "]";
                                    }
                                    String corpusline = "Corpus:" + corpus.getLuceneQuery() + "\n"
                                            + "Operation:" + op.getClass().getName() + "\n" + "Background:"
                                            + backgroundline + "\n" + "Parameters:" + parametersline + "\n";

                                    if (writer != null) {
                                        try {
                                            writer.append(corpusline);
                                            writer.append(op.getResultsCSVString());
                                        } catch (IOException e) {
                                            logger.error("Error writing file " + corpusline);
                                            logger.error(e);
                                        }
                                    } else {
                                        System.out.println(corpusline);
                                        System.out.println(op.getResultsCSVString());
                                    }
                                }
                            }
                    }
                }

    if (writer != null) {
        try {
            writer.close();
        } catch (IOException e) {
            logger.error(e);
        }
    }
}

From source file:patientmanagerv1.HomeController.java

@FXML
private void createNewProgressReport(javafx.event.ActionEvent event) throws IOException {
    saveEval();//from  w w  w. ja  v a 2s .c o  m

    DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy(HH:mm:ss)");
    Date date = new Date();
    //System.out.println(dateFormat.format(date));
    String alpha = dateFormat.format(date);
    String beta = alpha.replace(":", "");

    //writes the new report to the list
    File openProgressReportsList = new File(
            installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
    FileWriter fw = new FileWriter(openProgressReportsList, true);
    BufferedWriter bufferedwriter = new BufferedWriter(fw);
    fw.append(alpha + "\n");
    bufferedwriter.close();
    fw.close();

    //sets the new report as the current report
    File currentReport = new File(
            installationPath + "/userdata/" + firstName + lastName + dob + "/currentprogressreport.txt");
    FileWriter f = new FileWriter(currentReport, false);
    BufferedWriter b = new BufferedWriter(f);
    f.append(beta);
    b.close();
    f.close();

    //creates the folder for THIS progress report, and all blank progress report files
    File aNewProgressReport = new File(
            installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta);
    //System.out.println(alpha);

    try {
        aNewProgressReport.mkdir();
        // System.out.println("Hello World");
        //result = true;
    } catch (Exception e) {
        //System.out.println("directory not created: installationPath + \"/userdata/\" + firstName + lastName + dob + \"/ProgressNotes/\" + alpha");
    }

    File fN = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta
            + "/firstname.txt");
    FileWriter writ = new FileWriter(fN, true);
    BufferedWriter bw = new BufferedWriter(writ);
    writ.append(firstName);
    bw.close();
    writ.close();

    File lN = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta
            + "/lastname.txt");
    FileWriter writ1 = new FileWriter(lN, true);
    BufferedWriter bw1 = new BufferedWriter(writ1);
    writ1.append(lastName);
    bw1.close();
    writ1.close();

    File age = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta
            + "/age.txt");
    FileWriter writ2 = new FileWriter(age, true);
    BufferedWriter bw2 = new BufferedWriter(writ2);
    writ2.append("");
    bw2.close();
    writ2.close();

    //creates the "loaded" file & writes to the "loaded" file
    File newFile = new File(
            installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + "/loaded.txt");
    FileWriter fr = new FileWriter(newFile, false);
    BufferedWriter bufferedwriter2 = new BufferedWriter(fr);
    fr.append("false");
    bufferedwriter2.close();
    fr.close();

    //redirects to the progress note form
    Parent root3 = FXMLLoader.load(getClass().getResource("FXMLProgressReport.fxml"));
    Scene scene = new Scene(root3);
    Stage appStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
    appStage.setScene(scene);
    appStage.show();
}

From source file:patientmanagerv1.HomeController.java

@FXML
private void loadProgressReport(javafx.event.ActionEvent event) throws IOException {
    try {/*from   w  ww  .  ja  v a  2 s.c  o  m*/

        //sets current report
        String currRep = listOfProgressReports.getSelectionModel().getSelectedItem().toString();
        currRep = currRep.replace(":", "");
        //System.out.println("Selected Report is: " + currRep);

        File currentReport = new File(
                installationPath + "/userdata/" + firstName + lastName + dob + "/currentprogressreport.txt");
        FileWriter f = new FileWriter(currentReport, false);
        BufferedWriter b = new BufferedWriter(f);
        f.append(currRep);
        b.close();
        f.close();

        //creates the "loaded" file & writes to the "loaded" file
        File newFile = new File(
                installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/loaded.txt");
        FileWriter fr = new FileWriter(newFile, false);
        BufferedWriter bufferedwriter2 = new BufferedWriter(fr);
        fr.append("true");
        bufferedwriter2.close();
        fr.close();

        //redirects to the progress note form
        Parent root3 = FXMLLoader.load(getClass().getResource("FXMLProgressReport.fxml"));
        Scene scene = new Scene(root3);
        Stage appStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
        appStage.setScene(scene);
        appStage.show();

        /*
            DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy(HH:mm:ss)");
            Date date = new Date();
            //System.out.println(dateFormat.format(date));
            String alpha = dateFormat.format(date);
            String beta = alpha.replace(":", "");
                
                
        //writes the new report to the list
        File openProgressReportsList = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressReports.txt");
        FileWriter fw = new FileWriter(openProgressReportsList, true);           
        BufferedWriter bufferedwriter = new BufferedWriter(fw);
        fw.append(alpha + "\n");
        bufferedwriter.close();
        fw.close();
                
        //sets the new report as the current report
        File currentReport = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/currentprogressreport.txt");
        FileWriter f = new FileWriter(currentReport, false);           
        BufferedWriter b = new BufferedWriter(f);
        f.append(beta);
        b.close();
        f.close();
                
                
        //creates the folder for THIS progress report, and all blank progress report files
            File aNewProgressReport = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta);        
            System.out.println(alpha);
                
        try
        {
           aNewProgressReport.mkdir();
               // System.out.println("Hello World");
           //result = true;
        } 
               catch(Exception e)
        {
           System.out.println("directory not created: installationPath + \"/userdata/\" + firstName + lastName + dob + \"/ProgressNotes/\" + alpha");
        }  
                    
        File fN = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta + "/firstname.txt");
        FileWriter writ = new FileWriter(fN, true);           
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(firstName);
        bw.close();
        writ.close();
                
        File lN = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta + "/lastname.txt");
        FileWriter writ1 = new FileWriter(lN, true);           
        BufferedWriter bw1 = new BufferedWriter(writ1);
        writ1.append(lastName);
        bw1.close();
        writ1.close();
                
        File age = new File(installationPath + "/userdata/" + firstName + lastName + dob + "/ProgressNotes/" + beta + "/age.txt");
        FileWriter writ2 = new FileWriter(age, true);           
        BufferedWriter bw2 = new BufferedWriter(writ2);
        writ2.append("");
        bw2.close();
        writ2.close();
        */
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Please select a progress report from the list and try again");
    }
}

From source file:patientmanagerv1.HomeController.java

public void saveAge() {
    try {/*from   w  ww .  j av a  2  s .  c  o m*/
        File ageFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                + lastName.toLowerCase() + dob + "/EvaluationForm/age.txt");
        FileWriter writ = new FileWriter(ageFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(ageText.getText());
        bw.close();
        writ.close();

    } catch (IOException e) {
    }
}

From source file:patientmanagerv1.HomeController.java

public void saveLegalHistory() {
    try {/*www. j  a va2  s . c o  m*/
        File legalHistory = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                + lastName.toLowerCase() + dob + "/EvaluationForm/legalhistory.txt");
        FileWriter writ = new FileWriter(legalHistory, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(legalhistory.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
}

From source file:patientmanagerv1.HomeController.java

public void saveEducation() {
    try {// www.  j a  v  a2s  .c o m
        File educationFile = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                + lastName.toLowerCase() + dob + "/EvaluationForm/education.txt");
        FileWriter writ = new FileWriter(educationFile, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(education.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
}

From source file:patientmanagerv1.HomeController.java

public void saveSocialHistory() {
    try {/*from   ww  w .j  av a 2 s. com*/
        File socialHistory = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                + lastName.toLowerCase() + dob + "/EvaluationForm/socialhistory.txt");
        FileWriter writ = new FileWriter(socialHistory, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(socialhistorygeneral.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
}

From source file:patientmanagerv1.HomeController.java

public void savePastMedicalHistory() {
    try {//from   w  ww .  ja va 2  s  .c  o m
        File medicalHistory = new File(installationPath + "/userdata/" + firstName.toLowerCase()
                + lastName.toLowerCase() + dob + "/EvaluationForm/pastmedicalhistory.txt");
        FileWriter writ = new FileWriter(medicalHistory, false); //it is set to false so that it (the current patient) will be overwritten every time
        BufferedWriter bw = new BufferedWriter(writ);
        writ.append(pastmedicalhistory.getText());
        bw.close();
        writ.close();
    } catch (IOException e) {
    }
}