Guest User

Untitled

a guest
Jan 2nd, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package printfolder;
  6.  
  7. import java.io.File;
  8. import java.io.IOException;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11.  
  12. /**
  13.  *
  14.  * @author phani
  15.  */
  16. public class Main {
  17.  
  18.     public static String folder = "/opt/Print/Print";
  19.     public static String doneFolder = "/opt/Print/Printed";
  20.     static String[] cmd = new String[3];
  21.     static File print = new File(folder);
  22.     static String[] files;
  23.  
  24.     public static void main(String[] args) {
  25.         cmd[0] = "/bin/bash";
  26.         cmd[1] = "-c";
  27.         while (true) {
  28.             try {
  29.                 Thread.sleep(10000);
  30.             } catch (Exception e) {
  31.             }
  32.  
  33.             files = print.list();
  34.  
  35.             if (files != null) {
  36.                 for (int i = 0; i < files.length; i++) {
  37.                     try {
  38.                         cmd[2] = "notify-send -t 10000 \"Printing "+files[i]+" from the Print Folder\"";
  39.                         Runtime.getRuntime().exec(cmd);
  40.                         cmd[2] = "soffice -p " + folder + "/" + files[i];
  41.                         Runtime.getRuntime().exec(cmd).waitFor();
  42.                         try {
  43.                             Thread.sleep(1000);
  44.                         } catch (Exception e) {
  45.                         }
  46.                         cmd[2] = "mv " + folder + "/" + files[i] + " " + doneFolder + "/";
  47.                         Runtime.getRuntime().exec(cmd).waitFor();
  48.                     } catch (Exception ex) {
  49.                         Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  50.                     }
  51.                 }
  52.             }
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment