Here you can find the source of saveFile(File directory, String fileName, String content)
Parameter | Description |
---|---|
directory | the directory in which new file will be saved. |
fileName | the name of the created file. |
content | the content saved in the created file. |
Parameter | Description |
---|---|
IOException | IOException |
public static void saveFile(File directory, String fileName, String content) throws IOException
//package com.java2s; /**/*from w ww .j a v a 2s.co m*/ * AADL-RAMSES * * Copyright ? 2014 TELECOM ParisTech and CNRS * * TELECOM ParisTech/LTCI * * Authors: see AUTHORS * * This program is free software: you can redistribute it and/or modify * it under the terms of the Eclipse Public License as published by Eclipse, * either version 1.0 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 * Eclipse Public License for more details. * You should have received a copy of the Eclipse Public License * along with this program. If not, see * http://www.eclipse.org/org/documents/epl-v10.php */ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; public class Main { /** * This method save the String {@code content} in a file which name is * {@code fileName}. The file is saved in directory {@code directory}. * @param directory the directory in which new file will be saved. * @param fileName the name of the created file. * @param content the content saved in the created file. * @throws IOException {@link IOException} */ public static void saveFile(File directory, String fileName, String content) throws IOException { BufferedWriter output; FileWriter file = new FileWriter(directory.getAbsolutePath() + File.separator + fileName); output = new BufferedWriter(file); output.write(content); output.close(); } }