简体   繁体   English

通过 UI 上传或从目录读取在 Java Web 应用程序中处理巨大的文本文件

[英]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.我的 Web 应用程序需要处理一个文本文件(大小接近 200MB)以读取一些相关数据。 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?我应该允许用户通过应用程序本身上传这个 200mb 的文件然后处理它吗?

  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 eg'Start Processing')配置 java web 应用程序以从 tomcat 服务器中的预定义目录读取文件。(我仍然会向用户呈现一个 UI 来启动处理,例如“开始处理”)

I will be using JSaPAR library for processing my text file as it is a flat file with fixed positions.我将使用JSaPAR库来处理我的文本文件,因为它是一个位置固定的平面文件。

Let me answer the question myself.让我自己回答这个问题。

A pointed out by vikeng21 I will also prefer the 2nd option. vikeng21 指出我也更喜欢第二个选项。 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.还在 GUI 中添加了选项,通过从属性文件读取预配置的文件夹,显示可供系统处理的文件。 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.如果文件夹中没有可用文件,GUI 还会显示客户需要放置文件的绝对文件夹路径,以便应用程序可以读取和呈现文件信息。 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.还针对每个文件名呈现进程链接,单击该链接后,控制将转移到操作类,该类使用 java IO 框架读取文件,然后使用 JSAPAR 库对其进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM