用一个线程来监控这个folder,用一个文件或者数据库来记录你上一次扫描的时间,然后如果扫描到有文件的last modify time迟过你上一次扫描时间的话......如果你每次扫描后把文件搬到另一个目录就更简单了......

解决方案 »

  1.   

    其实就是设置一个对文件夹中文件的检测嘛!
    你每次把里面的文件名称全部存在一个容器里面(在java中有vector),然后获取及时的全部
    文件名称与之比较,如果里面没有就是新的那!
      

  2.   

    /*
     * Created on 2004/06/17
     *
     * To change the template for this generated file go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     */
    package playoffs.test.ftp;import java.io.IOException;
    import java.io.InputStream;
    import java.net.MalformedURLException;
    import java.net.URL;import sun.net.ftp.FtpClient;
    import sun.net.www.protocol.ftp.FtpURLConnection;/**
     * @author wangji
     *
     * To change the template for this generated type comment go to
     * Window>Preferences>Java>Code Generation>Code and Comments
     */
    public class FtpTest { private FtpURLConnection ftpConn;
    private FtpClient ftpClient;
    private URL url; public FtpTest(){ try {
    ftpClient = new FtpClient("xxx.xxx.xxx.xxx");
    } catch (IOException e) {
    e.printStackTrace();
    }
    try {
    ftpClient.login("xxxxx","xxxxxx");
    } catch (IOException e2) {
    e2.printStackTrace();
    }
    try {
    ftpClient.ascii();
    } catch (IOException e1) {
    e1.printStackTrace();
    }
    try {
    ftpClient.cd("xxxx/log");
    } catch (IOException e3) {
    e3.printStackTrace();
    }
    InputStream in = null;
    try {
    in = ftpClient.list();
    } catch (IOException e4) {
    e4.printStackTrace();
    }
    int x = 0;
    try {
    x = in.read();
    } catch (IOException e5) {
    e5.printStackTrace();
    }
    while(x!=-1){
    System.out.print((char)x);
    try {
    x = in.read();
    } catch (IOException e6) {
    e6.printStackTrace();
    }
    }
    // System.out.println(ftpClient.list().toString());
    String str = ftpClient.getResponseString();
    System.out.println(str);
    System.out.println("finish");
    try {
    url = new URL("ftp://xxx.xxx.xxx.x/xxxx/log/xxxxx.log");
    } catch (MalformedURLException e6) {
    e6.printStackTrace();
    }
    try {
    ftpConn = (FtpURLConnection) url.openConnection();
    } catch (IOException e9) {
    e9.printStackTrace();
    }
    try {
    InputStream reader = ftpConn.getInputStream();
    } catch (IOException e7) {
    e7.printStackTrace();
    }
    } public static void main(String[] args){
    new FtpTest();
    }
    }
      

  3.   

    支持  Arias(永恒之道) ( ) 的说法。
      

  4.   

    一个本地监听的大体思路File f = new File(root) //root,要查看的目录
    while(true){
      String[] fn = f.list(); //获取所有子File对象
      File tmp = null;
      for(int i=0;i<fn.length();i++){
        tmp = new File(fn[i])
        if(tmp.isDirectory()){
          继续朝下走两步
        }else{
          是文件了..入库入库,查查看以前有没有
          if(o,new.file 新文件){
             新来的,整吧....
          }
        }
      }
      //扫完了...太累了,改休息一下了
      try{
        Thread.sleep(1000*60); //让俺睡一分钟吧..整的累了
      }catch(Exception e){}
    }