Here you can find the source of saveMineField(File fileName, String mineField)
public static boolean saveMineField(File fileName, String mineField)
//package com.java2s; /*/* w ww . j av a 2 s. c o m*/ MineSweeper Version 1.0 Copyright (C) 2004, Hafeez Jaffer 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 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.io.*; public class Main { public static boolean saveMineField(File fileName, String mineField) { // make sure there are no null values assert (fileName != null); PrintWriter pos = null; // write this information to the file try { pos = new PrintWriter(new FileOutputStream(fileName, false), true); } catch (Exception e) { e.printStackTrace(System.out); } try { // write values // write the minefield pos.println(mineField); // close the file pos.close(); return true; } catch (Exception e1) { e1.printStackTrace(System.out); // close the file try { pos.close(); } catch (Exception e2) { e2.printStackTrace(System.out); } } return false; } }