public void save(String s, File f) { try { int saveNumber = 1; File file = new File(f.getAbsolutePath() + "/save.adv"); while (file.exists()) { file = new File(f.getAbsolutePath() + "/save" + saveNumber + ".adv"); saveNumber++; } file.createNewFile(); FileWriter fWriter = new FileWriter(file.getAbsoluteFile()); BufferedWriter bWriter = new BufferedWriter(fWriter); bWriter.write(s); bWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
/** * This function writes the generated relative overview to a file. * * @param f The file to write to. * @throws IOException Thrown if unable to open or write to the file. * @throws InsufficientDataException Thrown if unable to generate the overview. */ public void writeToFile(File f) throws IOException, InsufficientDataException { f.createNewFile(); FileWriter fw = new FileWriter(f); fw.write(generateOverviewText()); fw.close(); }