使用Java解压缩COMP-3数字 [英] Unpacking COMP-3 digit using Java
问题描述
我有一个包含一些COMP-3编码字段的文件.有人可以告诉我如何在下面的线程中测试此代码吗?
I have a file with some COMP-3 encoded fields. Can someone please tell me how do I test this code in below thread ?
我尝试过的代码是
BufferedReader br =新的BufferedReader(新的FileReader(FILENAME))){
BufferedReader br = new BufferedReader(new FileReader(FILENAME))) {
String sCurrentLine;
int i=0;
String bf =null;
while ((sCurrentLine = br.readLine()) != null) {
i++;
System.out.println("FROM BYTES ");
System.out.println(unpackData(sCurrentLine.getBytes(), 5));
for (int j = 0; j < sCurrentLine.length(); j++) {
char c = sCurrentLine.charAt(j);
bf =bf + (int)c;
}
以上代码未提供正确的结果. 我尝试了单列进行转换,但未返回正确的结果. 我的输入栏
Above code is not giving correct result. I tried single column to convert but it is not returning correct result. My input column
输入文件看起来像
我尝试了JRecord传递cbl抄写本和数据文件,它生成的Java代码给出了不同的结果 产生的输出
I tried out JRecord passing cbl copybook and data file, it generate Java Code which is giving not same result Generated output
必需的输出
cbl复制书如下图
推荐答案
如果您使用数据 比较本抄写本;您将看到它不匹配.
If you compare the copybook with the data; you will see it does not match.
特别是 Class-Order-edg 被定义为图片 9(3),但在文件中看起来是 binary .
In particular Class-Order-edg is defines as pic 9(3) but it looks like it is binary in the file.
Bils-count-edg看似要移位6个字节. 这与将Class-order-edg-> Country-no-edg字段更改为comp-3/comp一致.该字帖似乎已过期.
Bils-count-edg looks to be shifted 6 bytes. This is consistent with fields Class-order-edg --> Country-no-edg being changed to comp-3/comp. The copybook appears to be out of date.
这篇关于使用Java解压缩COMP-3数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!