2011-02-21 8 views
2

Java JNotify를 사용하여 디렉토리 이벤트를 수신 대기 중입니다.Windows에서 JNotify 구성

가 가 가

그러나, 나는 아래의 프로그램을 실행 해요 때마다 프로그램이 오류없이 아무것도 대신

즉시 종료되고 난 프로그램이 이벤트

기다려야한다고 생각
import net.contentobjects.jnotify.*; 


public class ListenFile 
{ 
    public static void main(String [] args) throws JNotifyException 
    { 
     String path = "C:/Users/noor/Desktop/Files"; 
     int mask = JNotify.FILE_CREATED | 
     JNotify.FILE_DELETED | 
     JNotify.FILE_MODIFIED| 
     JNotify.FILE_RENAMED; 

     boolean watchSubtree = true; 
     int watchID = JNotify.addWatch(path, mask, watchSubtree, new JNotifyListener(){ 

      @Override 
      public void fileCreated(int arg0, String arg1, String arg2) { 

       System.out.println("1"); 
      } 

      @Override 
      public void fileDeleted(int arg0, String arg1, String arg2) { 
       // TODO Auto-generated method stub 
       System.out.println("2"); 
      } 

      @Override 
      public void fileModified(int arg0, String arg1, String arg2) { 
       // TODO Auto-generated method stub 
       System.out.println("3"); 
      } 

      @Override 
      public void fileRenamed(int arg0, String arg1, String arg2, 
        String arg3) { 
       // TODO Auto-generated method stub 
       System.out.println("4"); 
      }}); 
     try 
     { 
       Thread.sleep(1000000); 
     } 
     catch (InterruptedException e1) 
     { 
     } 



    } 
} 
+0

프로그램을 추가하는 것을 잊었습니까? –

+0

여기에 프로그램의 일부가 있지만, 이것에 대해서만 jnotify를 시도하고 있습니다 – Noor

답변

1

여러분의 프로그램은 입력해야 while (true) {}; 루프 또는 응용 프로그램 종료를 허용하지 않는 catch 절 이후의 다른 루프.

+0

감사합니다. – Noor

관련 문제