Here you can find the source of fileWrite(String fileName, String str)
public static void fileWrite(String fileName, String str)
//package com.java2s; /*//from www . j a v a2 s. c o m **************************************************** * REsolution is an automatic software refactoring tool **************************************************** * Copyright (c) 2016, Wang Ying, Yin Hongjian, YU Hai, ZHU Zhiliang. * E-mail: yuhai@126.com * All rights reserved. * * This file is part of REsolution. * * REsolution 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. * * REsolution 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 REsolution. If not, see <http://www.gnu.org/licenses/>. * */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static void fileWrite(String fileName, String str) { File file = new File(fileName); FileOutputStream fopstream = null; try { fopstream = new FileOutputStream(file); fopstream.write(str.getBytes()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally { try { fopstream.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } public static void fileWrite(File file, String str) { FileOutputStream fopstream = null; try { fopstream = new FileOutputStream(file); fopstream.write(str.getBytes()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally { try { fopstream.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }