Here you can find the source of saveToFile(String data, File file)
Parameter | Description |
---|---|
data | the data |
file | the file |
Parameter | Description |
---|---|
IOException | Signals that an I/O exception has occurred. |
public static void saveToFile(String data, File file) throws IOException
//package com.java2s; /*//w w w . ja v a 2 s . c o m * Metadata Editor * @author Jiri Kremser * * * * Metadata Editor - Rich internet application for editing metadata. * Copyright (C) 2011 Jiri Kremser (kremser@mzk.cz) * Moravian Library in Brno * * 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 2 * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** * Save to file. * * @param data * the data * @param file * the file * @throws IOException * Signals that an I/O exception has occurred. */ public static void saveToFile(String data, File file) throws IOException { FileOutputStream fos = null; try { fos = new FileOutputStream(file); fos.write(data.getBytes()); } finally { if (fos != null) fos.close(); } } }