javafileparsing

Process huge text file in java web application via UI upload or read from directory


My web application needs to process a text file (size close to 200MB) for reading some relevant data. This text file needs to be processed monthly once, which means the contents of this text file varies monthly. I would like to know what is the best practice to implement the processing of this text file.

  1. Shall i allow the user to upload this 200mb file via the application itself and then process it?

  2. Configure the java webapplication to read the file from a predefined directory in the tomcat server.(Still i will present a UI to the user to initiate the processing, say e.g.'Start Processing')

I will be using JSaPAR library for processing my text file as it is a flat file with fixed positions.


Solution

  • Let me answer the question myself.

    A pointed out by vikeng21 I will also prefer the 2nd option. I implemented in such a way that, I have made the folder in which the files to be placed configurable via a property file. Also added options in the GUI which displays the files available for the system to process, by reading the pre-configured folder from the property file. If there are no files available in the folder, the GUI will also displays the absolute folder path to which the customer needs to place the files, so that the app can read and render the file info. A process link is also rendered against each file name, upon clicking on which the control transfers to an action class, which reads the file using java IO framework and then process the same using JSAPAR library.