IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

java service for getting the modified timestamp of all the files in a directory.

  • 1.  java service for getting the modified timestamp of all the files in a directory.

    Posted Thu May 12, 2011 01:47 PM

    Hi All!. I have a problem, I want to get the modified date of all the files in a directory. can anyone tell what is wrong with it? Here is my java service:

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String directory = IDataUtil.getString( pipelineCursor, “directory” );
    pipelineCursor.destroy();
    File folder = new File(“c:/”);
    File listOfFiles = folder.listFiles();
    for (int i = 0; i < listOfFiles.length; i++) {
    long datetime=listOfFiles[i].lastModified();
    Date date=new Date(datetime);
    MDList=date;
    }
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    String MDList = new String[1];
    MDList[0] = “date”;
    IDataUtil.put( pipelineCursor_1, “MDList”, MDList );
    pipelineCursor_1.destroy();

    directory is input and MDList is the output.

    :sad:


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: java service for getting the modified timestamp of all the files in a directory.

    Posted Thu May 12, 2011 03:41 PM

    hey ankit,

    I believe this is the solution for your query.

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    String directory = IDataUtil.getString( pipelineCursor, “directory” );
    pipelineCursor.destroy();
    File folder = new File(directory);
    File listOfFiles = folder.listFiles();
    String MDList=new String
    [listOfFiles.length]
    ;
    for (int i = 0; i < listOfFiles.length; i++) {
    long datetime=listOfFiles[i].lastModified();
    Date date=new Date(datetime);
    MDList[i]=date.toString();
    }
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put( pipelineCursor_1, “MDList”, MDList );
    pipelineCursor_1.destroy();

    Please do not forgot to import java.io.,java.util. in the shared tab.

    Thanks ,
    Amol.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 3.  RE: java service for getting the modified timestamp of all the files in a directory.

    Posted Fri May 13, 2011 08:02 AM