Announcement Announcement Module
No announcement yet.
Need help getting all filename strings Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help getting all filename strings


    Wondering if anyone can help us with this. We are using spring bat to iterate through all xml files in a directory. Unfortunately, we seem to be able to only get the first filename, and this is causing our logs to display the incorrect filename when there are multiple files to process.

    Here is the section causing us issues:

          public void beforeStep(StepExecution stepExecution) {
            "Processor beforestep ");
                ExecutionContext ecStep = stepExecution.getExecutionContext();
                if(!ecStep.isEmpty() && ecStep.containsKey("FOO_FILE")){
                            setAmrFileName(ecStep.getString("FOO_FILE")); //this is the line we try to set the filename
                      }catch(ClassCastException exception){                  // however we only ever get the first one when multiple
                            if(LOG.isDebugEnabled()){                              // files exist
    If anyone could help us understand what we are doing wrong, it would be greatly appreciated.
    Last edited by kmspring; Oct 22nd, 2010, 01:27 PM.

  • #2
    I can help you in this.
    May I know what kind of job you are using and more about your scenario.
    What do you do after you get files?


    • #3
      The purpose of the job is to process all xml files in a directory and then send emails based on the contents in the files.

      We have all that working with spring bat, the only remaining issue is that we can't seem to iterate through all the filenames in the directory. The object we are getting the file name from always has the first filename as its value. See the sample code i posted in the original message.

      I have attached the full class in case that helps. Thanks a lot for your help.


      • #4
        Where did you set AMR_FILE property in ExecutionContext.
        Does your Reader return NotificationRec object? If so, was that Object created from one of the xml files you are using?

        For the similar scenario like this, I used MultiresourceItemReader which takes all the matching files with the given regex and iteratively reads records from each file.
        Each read record is return to Processor. Your processor could do business logic on records.