Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package printfolder;
- import java.io.File;
- import java.io.IOException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- /**
- *
- * @author phani
- */
- public class Main {
- public static String folder = "/opt/Print/Print";
- public static String doneFolder = "/opt/Print/Printed";
- static String[] cmd = new String[3];
- static File print = new File(folder);
- static String[] files;
- public static void main(String[] args) {
- cmd[0] = "/bin/bash";
- cmd[1] = "-c";
- while (true) {
- try {
- Thread.sleep(10000);
- } catch (Exception e) {
- }
- files = print.list();
- if (files != null) {
- for (int i = 0; i < files.length; i++) {
- try {
- cmd[2] = "notify-send -t 10000 \"Printing "+files[i]+" from the Print Folder\"";
- Runtime.getRuntime().exec(cmd);
- cmd[2] = "soffice -p " + folder + "/" + files[i];
- Runtime.getRuntime().exec(cmd).waitFor();
- try {
- Thread.sleep(1000);
- } catch (Exception e) {
- }
- cmd[2] = "mv " + folder + "/" + files[i] + " " + doneFolder + "/";
- Runtime.getRuntime().exec(cmd).waitFor();
- } catch (Exception ex) {
- Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment