Here you can find the source of saveTextFile(String content, File file, boolean append)
Parameter | Description |
---|---|
content | - content that file may contain #param directory - directory to save the file in |
file | - the name and extension of the file |
Parameter | Description |
---|---|
IOException | an exception |
public static boolean saveTextFile(String content, File file, boolean append) throws IOException
//package com.java2s; /**//from w w w .ja v a 2 s . c om * Visual Tracer - An Application of Java Code Instrumentation using AspectJ * Copyright (C) 2010 * Carlos Correia - mail.cefc@gmail.com * Rute Oliveira - rute23@gmail.com * Manuel Menezes de Sequeira - manuel.sequeira@iscte.pt * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { /** * Create a file with name and extension based on file argument in a directory and with a content * @param content - content that file may contain * #param directory - directory to save the file in * @param file - the name and extension of the file * @return What? * @throws IOException */ public static boolean saveTextFile(String content, File file, boolean append) throws IOException { boolean response = true; BufferedWriter out = new BufferedWriter(new FileWriter(file, append)); out.write(content); out.close(); return response; } }