2

I have a program (deployed to JBOSS 5) that reads parameters from excel file.

The User may add/remove parameters from the excel file. However the code does not recognize the modified excel file until jboss restarts.

Should I make a conf. change or should I change something in the code to get the parameter changes in my code?

File file = new File(configurationFileName);
Workbook workbook;
try {
    workbook = Workbook.getWorkbook(file);

    Sheet sheet =
        workbook.getSheet(Constants.CONFIGURATION_SHEET_TAX_RATES);
    if (sheet != null) {
        for (int columnIndex = 0; columnIndex < sheet.getColumns();
             columnIndex++) {
            String headerValue =
                getCellContents(sheet, columnIndex, 0);
        }
    }
}
Cheesebaron
  • 24,131
  • 15
  • 66
  • 118
  • You should use [*Apache-poi*](http://poi.apache.org/download.html) Java API. It's very handy for Microsoft Office Tools. As you're dealing with Excel, It can be used for both XLS and XLSX. – Lion Jul 20 '12 at 23:18

2 Answers2

0

I think you can use FileWatchDog

0

Check this answer: File changed listener in Java

A good way is to use DefaultFileMonitor from Apache Commons VFS: http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs2/impl/DefaultFileMonitor.html

And an example on using that: http://tunatore.wordpress.com/category/apache-commons-vfs/

Community
  • 1
  • 1
Juha Palomäki
  • 26,385
  • 2
  • 38
  • 43