Java PrintWriter Write saveMineField(File fileName, String mineField)

Here you can find the source of saveMineField(File fileName, String mineField)

Description

save Mine Field

License

Open Source License

Declaration

public static boolean saveMineField(File fileName, String mineField) 

Method Source Code

//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;
    }
}

Related

  1. saveHeatmapTableCsv(PrintWriter wr, double[][] coefficients, String[] labelNames)
  2. saveLastExpInfo(String fileName, int[] info)
  3. saveLine(File file, String line)
  4. saveList(List list, OutputStream outs)
  5. saveMatrixAsADM(AtomicReferenceArray matrix, String path)
  6. saveProbabilityData(String file, double[] probabilities, double start, double dt)
  7. saveProcessedDataFile(double[][] data, String file)
  8. saveSet(Set set, File setFile, String encoding)
  9. saveSortedMap(Map map, File mapFile, String separator, String qualifier, String encoding)