简体   繁体   English

导入Java / Groovy的文本文件处理库?

[英]Import text file crunching library for Java/Groovy?

In a lot of real life implementations of applications we face the requirement to import some kind of (text) files. 在许多实际的应用程序实现中,我们面临着导入某种(文本)文件的要求。 Usually we would implement some (hardcoded?) logic to validate the file (eg. proper header, proper number of delimiters, proper date/time value,etc.). 通常我们会实现一些(硬编码?)逻辑来验证文件(例如正确的标题,适当的分隔符数,正确的日期/时间值等)。 Eventually also need to check for the existence of related data in a table (eg. value of field 1 in text file must have an entry in some basic data table). 最终还需要检查表中是否存在相关数据(例如,文本文件中字段1的值必须在某些基本数据表中有一个条目)。

While XML solves this (to some extend) with XSD and DTD, we end up hacking this again and again for proprietary text file formats. 虽然XML使用XSD和DTD解决了这个问题(在某种程度上),但我们最终一次又一次地破解了专有文本文件格式。

Is there any library or framework that allows the creation of templates similar to the xsd approach ? 是否有任何框架允许创建类似于xsd方法的模板 This would make it way more flexible to react on file format changes or implement new formats. 这样可以更灵活地对文件格式更改做出反应或实现新格式。

Thanks for any hints 谢谢你的任何提示

Sven 斯文

Closest thing I can think of is FileHelpers . 我能想到的最近的事情是FileHelpers It's in C#, so it would have to be ported to Java, but that shouldn't be a big deal. 它在C#中,因此必须移植到Java,但这不应该是一个大问题。

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

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