Esempio n. 1
0
  /**
   * Create/Replace a File
   *
   * @param Direct the Directory in which the File is made
   * @param Txt the Text to be written in the file
   */
  public void createFile(String Direct, String Txt) {
    File f = new File(Direct + File_Name);

    if (f.isFile()) { // Check if this file already exists
      if (JOptionPane.showConfirmDialog(
              null, "This file already exists, do you wish to replace it?", "Replace", 0)
          != 0) {
        return;
      }
      // Delete file
      f.delete();
    }

    try {
      // Replace/Create file
      f.createNewFile();
      // If file preference set to "File with displayed text", write text to file
      if (Txt != null) {
        WriteFile(f, Txt);
      }
      Msgs.Type("File created", Display);
    } catch (Exception e) {
      Msgs.Type("Unable to create this file", Display);
    }
  }
Esempio n. 2
0
  /**
   * Create/Replace a Directory
   *
   * @param Direct the Directory in which the new Directory is made
   */
  public void createDirectory(String Direct) {
    File dir = new File(Direct + File_Direct + "\\");

    if (dir.isDirectory()) { // Check if this directory already exists
      if (JOptionPane.showConfirmDialog(
              null, "This directory already exists, do you wish to replace it?", "Replace", 0)
          != 0) {
        return;
      }
      // Delete directory
      DeleteDirect(Direct + File_Direct + "\\");
    }
    // Replace/Create directory
    dir.mkdir();
    Msgs.Type("Directory created", Display);
  }