It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




7年前关闭。




欣赏是否有人可以指出并建议如何将平面管道分隔文件解析为JAVA Pojo。

例如。
平面文件
0001 | XYZ | 120

要求将其读入具有
public class pojo {

private String acct;
private String customer;
private int balance;
}

我可以将整个输入文件读取为集合,但是最终会将每个标记设置为pojo成员。相反,我想解析为pojo成员。与CASTOR XML映射到POJO类似。

感谢这方面的帮助。提前致谢

最佳答案

您可以使用Bean IO。我已经广泛使用了它。

像这样配置您的XML

<stream name="employees" format="delimited" strict="true">
  <parser>
    <property name="delimiter" value="|" />
  </parser>
  <record name="test" class="example.Pojo" minOccurs="1" maxOccurs="1">
      <field name="act" />
      <field name="customer" />
      <field name="balance" type="int" />
    </record>
 </stream>

有关更多详细信息,请参考here

07-24 19:01
查看更多