Example usage for java.io BufferedWriter newLine

List of usage examples for java.io BufferedWriter newLine

Introduction

In this page you can find the example usage for java.io BufferedWriter newLine.

Prototype

public void newLine() throws IOException 

Source Link

Document

Writes a line separator.

Usage

From source file:me.ryanhamshire.griefprevention.DataStore.java

private void saveSoftMutes() {
    BufferedWriter outStream = null;

    try {//from ww w . j  a v  a  2s  . co  m
        // open the file and write the new value
        File softMuteFile = softMuteFilePath.toFile();
        softMuteFile.createNewFile();
        outStream = new BufferedWriter(new FileWriter(softMuteFile));

        for (Map.Entry<UUID, Boolean> entry : softMuteMap.entrySet()) {
            if (entry.getValue().booleanValue()) {
                outStream.write(entry.getKey().toString());
                outStream.newLine();
            }
        }

    }

    // if any problem, log it
    catch (Exception e) {
        GriefPreventionPlugin.addLogEntry("Unexpected exception saving soft mute data: " + e.getMessage());
        e.printStackTrace();
    }

    // close the file
    try {
        if (outStream != null) {
            outStream.close();
        }
    } catch (IOException exception) {
    }
}

From source file:de.dfki.km.perspecting.obie.experiments.PhraseExperiment.java

/**
 * Test method for/* ww w.  j a v  a 2s  .c  o m*/
 * {@link de.dfki.km.perspecting.obie.dixi.service.SimpleScobieService#extractInformationFromURL(java.lang.String, java.lang.String)}
 * .
 */
@Test
public void analyseTokenPhraseFrequencies() {
    final String template = "SELECT * WHERE {?s ?p ?o}";

    try {
        final BufferedWriter bw = new BufferedWriter(
                new FileWriter($SCOOBIE_HOME + "results/token_phrase_frequency_wikipedia.csv"));

        final String randomWikipediaPage = "http://en.wikipedia.org/wiki/Special:Random";

        bw.append("tok in doc\tnp in doc\ttok in nps\tdistinct tok in nps\tdistinct tok in doc");
        for (int i = 0; i < 100; i++) {

            Document document = pipeline.createDocument(FileUtils.toFile(new URL(randomWikipediaPage)),
                    new URI(randomWikipediaPage), MediaType.HTML, template, Language.EN);

            for (int step = 0; pipeline.hasNext(step) && step <= 5; step = pipeline.execute(step, document)) {
                System.out.println(step);
            }

            HashSet<String> wordsOfPhrases = new HashSet<String>();
            HashSet<String> wordsOfDocument = new HashSet<String>();

            for (Token token : document.getTokens()) {
                wordsOfDocument.add(token.toString());
            }

            int count = 0;
            for (TokenSequence<String> np : document.getNounPhrases()) {
                String[] words = np.toString().split("[\\s]+");
                count += words.length;
                wordsOfPhrases.addAll(Arrays.asList(words));
            }

            bw.append(document.getTokens().size() + "\t" + document.getNounPhrases().size() + "\t" + count
                    + "\t" + wordsOfPhrases.size() + "\t" + wordsOfDocument.size());
            bw.newLine();

        }
        bw.close();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {
        final BufferedWriter bw = new BufferedWriter(
                new FileWriter($SCOOBIE_HOME + "results/token_phrase_frequency_reuters.csv"));

        final TextCorpus corpus = new TextCorpus(new File("../corpora/reuters/reuters.zip"), MediaType.ZIP,
                MediaType.HTML, Language.EN);

        bw.append("tok in doc\tnp in doc\ttok in nps\tdistinct tok in nps\tdistinct tok in doc");

        corpus.forEach(new DocumentProcedure<URI>() {

            @Override
            public URI process(Reader reader, URI uri) throws Exception {

                Document document = pipeline.createDocument(reader, uri, corpus.getMediatype(), template,
                        corpus.getLanguage());

                for (int step = 0; pipeline.hasNext(step)
                        && step <= 5; step = pipeline.execute(step, document)) {
                    System.out.println(step);
                }

                HashSet<String> wordsOfPhrases = new HashSet<String>();
                HashSet<String> wordsOfDocument = new HashSet<String>();

                for (Token token : document.getTokens()) {
                    wordsOfDocument.add(token.toString());
                }

                int count = 0;
                for (TokenSequence<String> np : document.getNounPhrases()) {
                    String[] words = np.toString().split("[\\s]+");
                    count += words.length;
                    wordsOfPhrases.addAll(Arrays.asList(words));
                }

                bw.append(document.getTokens().size() + "\t" + document.getNounPhrases().size() + "\t" + count
                        + "\t" + wordsOfPhrases.size() + "\t" + wordsOfDocument.size());
                bw.newLine();
                return uri;
            }
        });

        bw.close();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:gdsc.smlm.ij.plugins.TraceDiffusion.java

private void saveStatistics(StoredDataStatistics stats, String title, String label, boolean rounded) {
    if (!directoryChosen)
        rawDataDirectory = Utils.getDirectory("Data_directory", rawDataDirectory);
    directoryChosen = true;/*from  w w  w . ja v a  2  s .  c om*/
    if (rawDataDirectory == null)
        return;
    String filename = rawDataDirectory + title.replace("/", " per ").replace("*", "star") + ".txt";

    BufferedWriter out = null;
    try {
        FileOutputStream fos = new FileOutputStream(filename);
        out = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
        out.write(label);
        out.newLine();
        double[] data = stats.getValues();
        Arrays.sort(data);
        if (rounded) {
            for (double d : data) {
                out.write(Utils.rounded(d, 4));
                out.newLine();
            }
        } else {
            for (double d : data) {
                out.write(Double.toString(d));
                out.newLine();
            }
        }
    } catch (Exception e) {
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            }
        }
    }
}

From source file:analytics.storage.store2csv.java

@Override
public void storeElementData(HashMap<String, Double> data, String metricName, String dataProvider,
        String analysisType, String headerColumn, Boolean fed) {
    // TODO Auto-generated method stub

    String sFileName = dataProvider + analysisType + ".csv";

    Properties props = new Properties();
    try {//from w ww.jav  a 2 s.  c  om
        props.load(new FileInputStream("configure.properties"));
    } catch (FileNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        System.exit(-1);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        System.exit(-1);
    }

    File anls = new File(props.getProperty(AnalyticsConstants.resultsPath) + "Analysis_Results");

    if (!anls.exists())
        anls.mkdir();

    File dir = new File(anls, dataProvider);
    if (!dir.exists())
        dir.mkdir();

    File file = new File(dir, sFileName);

    this.setElementDataFilePath(file.getAbsolutePath());
    FileWriter writer = null;
    BufferedWriter bw = null;

    BufferedReader reader = null;
    try {

        if (file.exists() && isAppendData() == false) {

            if (fed == false)
                file.delete();
            setAppend(true);
        } else if (!file.exists() && isAppendData() == false)
            setAppend(true);

        if (!file.exists() && isAppendData() == true) {
            writer = new FileWriter(file);
            bw = new BufferedWriter(writer);
            createHeaders(bw, metricName, headerColumn);

            Set<String> keySet = data.keySet();
            Iterator<String> iterator = keySet.iterator();

            StringBuffer key = new StringBuffer();
            while (iterator.hasNext()) {
                // String key = iterator.next();
                key.append(iterator.next());
                // System.out.println(key);
                bw.append(key.toString());
                bw.append(',');
                Double value = data.get(key.toString());
                bw.append(String.valueOf(value));
                bw.newLine();
                key.delete(0, key.length());
            }

            bw.close();
            writer.close();
        } else if (file.exists() && isAppendData() == true) {

            reader = new BufferedReader(new FileReader(file));

            File temp = new File(dir, "temp.csv");

            writer = new FileWriter(temp);
            bw = new BufferedWriter(writer);

            String line;
            int counter = 0;

            // Set<String> keySet = data.keySet();
            // Iterator<String> iterator = keySet.iterator();

            StringBuffer key = new StringBuffer();
            while ((line = reader.readLine()) != null) {

                String[] split = line.split(",");

                // String key = split[0];
                key.append(split[0]);

                if (counter == 0) {
                    line = line + "," + metricName;
                    bw.append(line);
                    bw.newLine();

                } else {

                    Double value = data.get(key.toString());
                    // System.out.println("Appending key:" + key +
                    // " value:"
                    // + value);
                    line = line + "," + value;
                    // /System.out.println("Appending line:" + line);
                    bw.append(line);
                    bw.newLine();
                }

                counter += 1;
                key.delete(0, key.length());

            }
            bw.close();
            writer.close();

            FileUtils.copyFile(temp, file);
            temp.delete();
            reader.close();

        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (bw != null)
                bw.close();
            if (reader != null)
                reader.close();
            if (writer != null)
                writer.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

From source file:com.github.seqware.queryengine.system.exporters.VCFDumper.java

/**
 * <p>dumpVCFFromFeatureSetID.</p>
 *
 * @param fSet a {@link com.github.seqware.queryengine.model.FeatureSet} object.
 * @param file a {@link java.lang.String} object.
 *///  www.  j  a  va  2s  .c  o  m
public static void dumpVCFFromFeatureSetID(FeatureSet fSet, String file) {
    BufferedWriter outputStream = null;

    try {
        if (file != null) {
            outputStream = new BufferedWriter(new FileWriter(file));
        } else {
            outputStream = new BufferedWriter(new OutputStreamWriter(System.out));
        }
        outputStream.append("#CHROM   POS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n");
    } catch (IOException e) {
        Logger.getLogger(VCFDumper.class.getName()).fatal("Exception thrown starting export to file:", e);
        System.exit(-1);
    }

    boolean caughtNonVCF = false;
    boolean mrSuccess = false;
    if (SWQEFactory.getQueryInterface() instanceof MRHBasePersistentBackEnd) {
        // hack to use VCF MR
        if (SWQEFactory.getModelManager() instanceof MRHBaseModelManager) {
            try {
                // pretend that the included com.github.seqware.queryengine.plugins.hbasemr.MRFeaturesByAttributesPlugin is an external plug-in
                Class<? extends PluginInterface> arbitraryPlugin;
                arbitraryPlugin = VCFDumperPlugin.class;
                // get a FeatureSet from the back-end
                QueryFuture<File> future = SWQEFactory.getQueryInterface().getFeaturesByPlugin(0,
                        arbitraryPlugin, fSet);
                File get = future.get();
                BufferedReader in = new BufferedReader(new FileReader(get));
                IOUtils.copy(in, outputStream);
                in.close();
                get.deleteOnExit();
                outputStream.flush();
                outputStream.close();
                mrSuccess = true;
            } catch (IOException e) {
                // fail out on IO error
                Logger.getLogger(VCFDumper.class.getName()).fatal("Exception thrown exporting to file:", e);
                System.exit(-1);
            } catch (Exception e) {
                Logger.getLogger(VCFDumper.class.getName())
                        .info("MapReduce exporting failed, falling-through to normal exporting to file");
                // fall-through and do normal exporting if Map Reduce exporting fails
            }
        } // TODO: clearly this should be expanded to include closing database etc 
    }
    if (mrSuccess) {
        return;
    }
    // fall-through if plugin-fails
    try {
        for (Feature feature : fSet) {
            StringBuffer buffer = new StringBuffer();
            boolean caught = outputFeatureInVCF(buffer, feature);
            if (caught) {
                caughtNonVCF = true;
            }
            outputStream.append(buffer);
            outputStream.newLine();
        }
        outputStream.flush();
    } catch (IOException e) {
        Logger.getLogger(VCFDumper.class.getName()).fatal("Exception thrown exporting to file:", e);
        System.exit(-1);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}

From source file:gdsc.smlm.ij.plugins.TraceDiffusion.java

private void saveMSD(double[] x, double[] y, double[] se) {
    if (!directoryChosen)
        rawDataDirectory = Utils.getDirectory("Data_directory", rawDataDirectory);
    directoryChosen = true;/*  ww w .  ja v  a2s . c  o m*/
    if (rawDataDirectory == null)
        return;
    String filename = rawDataDirectory + "MSD.txt";

    BufferedWriter out = null;
    try {
        FileOutputStream fos = new FileOutputStream(filename);
        out = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8"));
        out.write("Time (s)\tDistance (um^2)\tS.E.");
        out.newLine();
        for (int i = 0; i < x.length; i++) {
            out.write(Utils.rounded(x[i]));
            out.write('\t');
            out.write(Double.toString(y[i]));
            out.write('\t');
            out.write(Double.toString(se[i]));
            out.newLine();
        }
    } catch (Exception e) {
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
            }
        }
    }
}

From source file:ffx.ui.KeywordPanel.java

/**
 * <p>/*from  ww w . j  a va 2 s . c  om*/
 * saveKeywords</p>
 *
 * @param keyFile a {@link java.io.File} object.
 * @param keywordHashMap a {@link java.util.LinkedHashMap} object.
 * @param comments a {@link java.lang.StringBuilder} object.
 * @return a boolean.
 */
public boolean saveKeywords(File keyFile, LinkedHashMap<String, KeywordComponent> keywordHashMap,
        StringBuilder comments) {
    synchronized (this) {
        FileWriter fw = null;
        BufferedWriter bw = null;
        try {
            fw = new FileWriter(keyFile);
            bw = new BufferedWriter(fw);
            boolean writegroup = false;
            String pgroup = null;
            // Write out keywords in groups
            for (KeywordComponent keyword : keywordHashMap.values()) {
                String group = keyword.getKeywordGroup();
                if (pgroup == null || !group.equalsIgnoreCase(pgroup)) {
                    writegroup = true;
                    pgroup = group;
                }
                String line = keyword.toString();
                if (line != null) {
                    if (writegroup == true) {
                        bw.newLine();
                        bw.write("# " + group);
                        bw.newLine();
                        writegroup = false;
                    }
                    bw.write(line);
                    bw.newLine();
                }
            }
            bw.newLine();
            String s = comments.toString();
            if (s != null && !s.trim().equals("")) {
                bw.write(s.trim());
            }
            bw.newLine();
            bw.flush();
            KeywordComponent.setKeywordModified(false);
        } catch (FileNotFoundException e) {
            logger.warning(e.toString());
            return false;
        } catch (IOException e) {
            logger.warning(e.toString());
            return false;
        } finally {
            try {
                if (bw != null) {
                    bw.close();
                }
                if (fw != null) {
                    fw.close();
                }
            } catch (Exception e) {
                logger.warning(e.toString());
            }
        }
        return true;
    }
}

From source file:com.thalesgroup.hudson.plugins.klocwork.util.KloXMLGenerator.java

public static String GenerateXMLFromIssues(String a_host, String a_port, boolean useSSL, String a_projectname,
        String a_filename, BuildListener listener, String a_query, String a_user) {
    String kwurl = "";
    if (useSSL) {
        kwurl = "https://" + a_host + ":" + a_port;
    } else {//from w  ww  . j  a  va 2s  . c  om
        kwurl = "http://" + a_host + ":" + a_port;
    }
    listener.getLogger().println("Connecting to Klocwork Web API service... " + kwurl);
    KWApi KWservice = new KWApi(kwurl);

    try {
        listener.getLogger().println("creating XML document");
        File outputFile = new File(a_filename);
        if (outputFile.exists()) {
            outputFile.delete();
        }
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new FileWriter(outputFile));
            if (outputFile.canWrite()) {
                //Get issues
                listener.getLogger().println("Retrieving Klocwork issues using kwjlib...");
                listener.getLogger()
                        .println("Sending request for project: " + a_projectname + " with query: " + a_query);
                ArrayList<JSONObject> issues = KWservice.search(a_projectname, a_query, null, null, null);
                if (issues != null) {
                    listener.getLogger().println("Number of issues returned: " + issues.size());
                    bw.write(
                            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><errorList xmlns=\"http://www.klocwork.com/inForce/report/1.0\">");
                    //Iterate through issues
                    for (JSONObject issue : issues) {
                        if (issue != null) {
                            try {
                                if (issue.has("id") && issue.optString("id").length() > 0) {
                                    String id = StringEscapeUtils.escapeXml(issue.optString("id"));
                                    String file = StringEscapeUtils.escapeXml(issue.optString("file"));
                                    String method = StringEscapeUtils.escapeXml(issue.optString("method"));
                                    String code = StringEscapeUtils.escapeXml(issue.optString("code"));
                                    String message = StringEscapeUtils.escapeXml(issue.optString("message"));
                                    String status = StringEscapeUtils.escapeXml(issue.optString("status"));
                                    String state = StringEscapeUtils.escapeXml(issue.optString("state"));
                                    String owner = StringEscapeUtils.escapeXml(issue.optString("owner"));
                                    String severity = StringEscapeUtils.escapeXml(issue.optString("severity"));
                                    String severityCode = StringEscapeUtils
                                            .escapeXml(issue.optString("severityCode"));
                                    String taxonomyName = StringEscapeUtils
                                            .escapeXml(issue.optString("taxonomyName"));
                                    String url = StringEscapeUtils.escapeXml(issue.optString("url"));
                                    bw.write("<problem>");
                                    bw.newLine();
                                    bw.write("<problemID>" + id + "</problemID>");
                                    bw.newLine();
                                    bw.write("<file>" + file + "</file>");
                                    bw.newLine();
                                    bw.write("<method>" + method + "</method>");
                                    bw.newLine();
                                    bw.write("<code>" + code + "</code>");
                                    bw.newLine();
                                    bw.write("<message>" + message + "</message>");
                                    bw.newLine();
                                    bw.write("<citingStatus>" + status + "</citingStatus>");
                                    bw.newLine();
                                    bw.write("<state>" + state + "</state>");
                                    bw.newLine();
                                    bw.write("<owner>" + owner + "</owner>");
                                    bw.newLine();
                                    bw.write("<severity>" + severity + "</severity>");
                                    bw.newLine();
                                    bw.write("<severitylevel>" + severityCode + "</severitylevel>");
                                    bw.newLine();
                                    bw.write("<displayAs>" + severity + "</displayAs>");
                                    bw.newLine();
                                    bw.write("<taxonomies>");
                                    bw.newLine();
                                    bw.write("<taxonomy name=\"" + taxonomyName + "\" metaInf=\"\" />");
                                    bw.newLine();
                                    bw.write("</taxonomies>");
                                    bw.newLine();
                                    bw.write("<url>" + url + "</url>");
                                    bw.newLine();
                                    bw.write("</problem>");
                                    bw.newLine();
                                }
                            } catch (Exception e) {
                                listener.getLogger().println("[ERROR]: " + e.getMessage());
                                listener.getLogger().println("\tissue: " + issue.toString());
                                e.printStackTrace();
                            }
                        }
                    }
                    bw.write("</errorList>");
                } else {
                    listener.getLogger().println("ERROR: Unable to get issues from Klocwork server");
                    if (!KWservice.errorMessage.isEmpty()) {
                        for (JSONObject message : KWservice.errorMessage) {
                            listener.getLogger().println("\t" + message.toString());
                        }
                        KWservice.errorMessage.clear();
                    }
                    return "1";
                }
            } else {
                listener.getLogger()
                        .println("ERROR while generating XML. Could not open file for writing: " + a_filename);
            }
        } finally {
            if (bw != null) {
                bw.close();
            }
        }
    } catch (IOException ioe) {
        listener.getLogger().println("ERROR while generating XML - IOException:" + ioe.getMessage());
        return "1";
    }
    File outputFile = new File(a_filename);
    if (outputFile.exists() && outputFile.length() > 0) {
        listener.getLogger().println("Creation of XML file complete. Closing connection to Web API.");
    } else {
        listener.getLogger().println(
                "Creation of XML file failed. You may have to run the kwauth command on your machine.");
    }
    return "0";
}

From source file:json_csv.JSON2CSV.java

public void printIngredientToCSV(Recipe recipe, BufferedWriter ibw) {

    Recipe newRecipe = recipe;//  w  ww  .  j a  va  2 s.  co m
    Ingredient ingredient = null;
    StringBuffer oneLine = null;
    BufferedWriter newIbw = ibw;

    //String[] header = {"INGREDIENT_ID", "AISLE", "NAME", "AMOUNT", "ORIGINAL_STRING", "IMAGE", "UNIT", "UNIT_SHORT",
    //        "UNIT_LONG", "RECIPE_ID"};

    try {
        System.out.println(newRecipe.getExtendedIngredients().size());

        for (int i = 0; i < newRecipe.getExtendedIngredients().size(); i++) {

            ingredient = newRecipe.getExtendedIngredients().get(i);
            oneLine = new StringBuffer();

            oneLine.append(ingredient.getIngredientID());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getAisle().replace(",", ";"));
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getName());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getAmount());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append((ingredient.getOriginalString().replace(",", " ")));
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getImage());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getUnit());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getUnitShort());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(ingredient.getUnitLong());
            oneLine.append(CSV_SEPARATOR);
            oneLine.append(recipe.getId());

            ibw.write(oneLine.toString());
            ibw.newLine();

        }
    } catch (UnsupportedEncodingException e) {
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
    }

}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.util.DownloadNCBITraceXML.java

public void saveFullXMLFiles(int p) {

    BufferedReader br = null;/*from   ww w.j  a  va  2s .c o  m*/
    BufferedWriter bw = null;

    try {
        String pagesquery = "http://www.ncbi.nlm.nih.gov/Traces/trace.cgi?&cmd=retrieve&val=PROJECT_NAME%3D%22TCGA%22%20and%20LOAD_DATE%3E%3D%22"
                + latestLoaddate + "%22&size=" + querysize + "&dopt=xml_info&dispmax=" + pagesize + "&page="
                + p;
        //String pagesquery = "http://www.ncbi.nlm.nih.gov/Traces/trace.cgi?&cmd=retrieve&val=project_name%3D%22TCGA%22%20and%20load_date%3E%3D%2204%2F09%2F2008%22&dopt=info&size=490552&dispmax=5&page=4&next=%3E%3E
        URL url = new URL(pagesquery);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        //System.out.println( "url = " + url );
        is = connection.getInputStream();
        //noinspection IOResourceOpenedButNotSafelyClosed
        br = new BufferedReader(new InputStreamReader(is));
        String line;
        fw = new FileWriter(downloaddir + File.separator + xmlfiles + "." + p + ".xml");
        //fw= new FileWriter("C:\\larry\\WorkingDoc\\"+ latestLoaddate + "\\" + xmlfiles + "." + p + ".xml");
        //noinspection IOResourceOpenedButNotSafelyClosed
        bw = new BufferedWriter(fw);
        bw.write("<traces>");
        while ((line = br.readLine()) != null) {
            for (int i = 0; i < allFieldsWeCare.length; i++) {
                if (line.contains(allFieldsWeCare[i])) {
                    if (line.contains("<pre><trace>")) {
                        line = "<trace>";
                        //System.out.println(line);
                        bw.write(line);
                        bw.newLine();
                    } else {
                        //System.out.println(line);
                        bw.write(line);
                        bw.newLine();
                    }
                }
            }
        }
        bw.write("</traces>");
        is.close();
        connection.disconnect();
    } catch (MalformedURLException e) {
        getLogger().logToLogger(Level.ERROR,
                "DownloadNCBITraceXML saveXMLFiles MalformedURLException " + e.toString());
    } catch (IOException e) {
        getLogger().logToLogger(Level.ERROR, "DownloadNCBITraceXML saveXMLFiles IOException " + e.toString());
    } finally {
        IOUtils.closeQuietly(br);
        IOUtils.closeQuietly(bw);
    }
}