Esempio n. 1
0
 // creaza si deschide fisierul cu numele specificat
 public void mkfile(String fileName) {
   try {
     File newFile = new File(currentPath + "\\" + fileName);
     if (newFile.exists()) {
       System.out.println("Unable to create " + newFile.getAbsolutePath());
     } else {
       newFile.createNewFile();
       System.out.println("Directory" + fileName + "created");
       openFile(fileName);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     takePath();
   }
 }
Esempio n. 2
0
 public static void addDiskRefernce(String output) {
   BufferedWriter writer = null;
   try {
     // writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("log.txt")));
     writer = new BufferedWriter(new FileWriter("disks.txt", true));
     writer.write(output + "\n");
   } catch (IOException ex) {
     // report
   } finally {
     try {
       writer.close();
     } catch (Exception ex) {
         /*ignore*/
       ex.printStackTrace();
     }
   }
 }
Esempio n. 3
0
  public static void runtimeCall(String command, Console c) {
    try {
      String[] arguments = command.split("\\s+");

      if (arguments.length == 2) {
        Method m = Console.class.getMethod(arguments[0], String.class);
        m.invoke(c, arguments[1]);
      } else if (arguments.length == 1) {
        Method m = Console.class.getMethod(arguments[0]);
        m.invoke(c);
      } else if (arguments.length == 3) {
        Class[] array = {String.class, String.class};
        Method m = Console.class.getMethod(arguments[0], array);
        m.invoke(c, arguments[1], arguments[2]);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }