将 EBCDIC 字符串转换为 ASCII 格式?
我有一个从 Db2 表中提取的平面文件,该平面文件包含字符格式和打包十进制格式的记录。如何将打包数据转换为 java 字符串。有什么方法可以转换整个数据吗?平面文件转换为 ASCII 格式。
I am having a flat file which is pulled from a Db2 table ,the flat file contains records in both the char format as well as packed decimal format.how to convert the packed data to a java string.is there any way to convert the entire flat file to ASCII format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
EBCDIC 是一个编码系列。您需要更详细地了解您所追求的 EBCDIC 编码。
Java 有许多支持的编码 ,包括:
尝试一下,看看会得到什么。像这样的东西:
EBCDIC is a family of encodings. You'll need to know more in details which EBCDIC encoding you're after.
Java has a number of supported encodings, including:
Try those and see what you get. Something like:
将文件读取为字符串,将其写入 EBCDIC。使用OutputStreamWriter和InputStreamWriter并在构造函数中给出编码。
Read the file as a String, write it as EBCDIC. Use the OutputStreamWriter and InputStreamWriter and give the encoding in the constructor.
继 PAP 之后,CP037 是 US EBCDIC 编码。
另请查看 JRecord 项目。它允许您读取带有 Cobol 或 Xml 描述的文件,并将处理 EBCDIC 和 Comp-3。
最后,这是一个将打包十进制字节转换为字符串的例程,请参阅 转换
Following from PAP, CP037 is US EBCDIC encoding.
Also have a look at JRecord Project. It allows you to read a file with either a Cobol or Xml description and will handle EBCDIC and Comp-3.
Finally here is a routine to convert packed decimal bytes to String see method getMainframePackedDecimal in Conversion
分享我的示例代码供您参考:
Sharing a sample code by me for your reference: