有没有一种聪明的方法来编写固定长度的平面文件? [英] Is there an smart way to write a fixed length flat file?

查看:134
本文介绍了有没有一种聪明的方法来编写固定长度的平面文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何框架/库可以帮助在java中编写固定长度的平面文件?

Is there any framework/library to help writing fixed length flat files in java?

我想将bean /实体的集合写入平面文件而不用担心转换,填充,对齐,填充等等

I want to write a collection of beans/entities into a flat file without worrying with convertions, padding, alignment, fillers, etcs

例如,我想解析一个bean,如:

For example, I'd like to parse a bean like:

public class Entity{
    String name = "name"; // length = 10; align left; fill with spaces
    Integer id = 123; // length = 5; align left; fill with spaces
    Integer serial = 321 // length = 5; align to right; fill with '0'
    Date register = new Date();// length = 8; convert to yyyyMMdd
}

...进入......

... into ...

name      123  0032120110505
mikhas    5000 0122120110504
superuser 1    0000120101231

...

推荐答案

如果您还在寻找框架,请访问 http://www.beanio.org

If you are still looking for a framework, check out BeanIO at http://www.beanio.org

这篇关于有没有一种聪明的方法来编写固定长度的平面文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆