Here you can find the source of writeFile(String filename, String data)
public static void writeFile(String filename, String data) throws IOException
//package com.java2s; /*/*from w ww. j a va2s.co m*/ * BioJava development code * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. If you do not have a copy, * see: * * http://www.gnu.org/copyleft/lesser.html * * Copyright for this code is held jointly by the individual * authors. These should be listed in @author doc comments. * * For more information on the BioJava project and its aims, * or to join the biojava-l mailing list, visit the home page * at: * * http://www.biojava.org/ * * Created on Nov 4, 2016 * Author: blivens * */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; public class Main { public static void writeFile(String filename, String data) throws IOException { if (filename == null || filename.isEmpty() || filename.equals("-")) { System.out.println(data); } else { filename = expandUserHome(filename); File file = new File(filename); try (PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(file)))) { writer.println(data); } } } public static String expandUserHome(String file) { if (file.startsWith("~" + File.separator)) { file = System.getProperty("user.home") + file.substring(1); } return file; } }