Ejemplo n.º 1
0
    public void actionPerformed(ActionEvent e) {
      System.out.println(backEnd);

      try {
        FileWriter f = new FileWriter(output);
        f.write(backEnd.toString());
        f.close();
      } catch (IOException a) {
        JOptionPane.showMessageDialog(null, "Error loading file to save to.");
      }
    }
Ejemplo n.º 2
0
  public static void stringToFile(String file, String string) {
    try {
      if (file.lastIndexOf('\\') != -1) {
        File par = new File(file.substring(0, file.lastIndexOf('\\')));
        par.mkdirs();
      }

      FileWriter fw = new FileWriter(file);
      fw.write(string);
      fw.flush();
      fw.close();
    } catch (IOException e) {
      System.out.println("Failed to save file.");
    }
  }