简体   繁体   English

如何从Jpos ISO8583打包文件中读取所有记录,其中包含一行中的所有记录

[英]How to read all records from Jpos ISO8583 packaged file which contains all records in one line

I have ISO packaged file contains all its records on single line. 我有ISO打包文件包含单行的所有记录。 File contents like MTI1XXXXXXMTI2XXXXMTI1XXXXX So here total 3 rows which are on single line. 像MTI1XXXXXXMTI2XXXXMTI1XXXXX这样的文件内容所以这里共有3行在单行上。

ISOMsg isoMsg = new ISOMsg(); 
isoMsg.setPackager(packager); 
isoMsg.unpack(filedata);`

isoMsg only able to unpack first record MTI1XXXXXX isoMsg只能解压第一个记录MTI1XXXXXX

Here MTI1, MTI2, MTI3 are Message Type Indicator (MTI) which is of 4 digits. 这里MTI1,MTI2,MTI3是4位数的消息类型指示符(MTI)。

If I separate those records(3 lines) in file and read line by line like below 如果我将这些记录(3行)分开并逐行读取,如下所示

MTI1XXXXXX
MTI2XXXX
MTI1XXXXX

It returns me all the records. 它返回了我的所有记录。 Is there any way to read all records which are on single line using JPOS ISO8583 packager or with generic packager? 有没有办法使用JPOS ISO8583打包器或通用打包器读取所有单行记录?

adding my sample code snippet: 添加我的示例代码段:

InputStream lis = null;
    try {
        GenericPackager packager;
        packager = new GenericPackager("src/main/resources/BitMapConfig.xml");
        lis = new FileInputStream("src/test/resources/isoTestFile");
        ISOMsg isoMsg = new ISOMsg();
        isoMsg.setPackager(packager);
        isoMsg.unpack(lis);
        ISOBitMap bitmap = (ISOBitMap) isoMsg.getComponent(-1);
        System.out.println("bitmap.getValue::" + bitmap.getValue()); //returns only first records bitmap whoever file contains 3 MTI on single line
    } catch (Exception e) {
        e.printStackTrace();
    } 

I want to read all of those and separate those in different files. 我想阅读所有这些并将它们分成不同的文件。

You can try something like this: 你可以尝试这样的事情:

InputStream lis = null;
    try {
        GenericPackager packager;
        packager = new GenericPackager("src/main/resources/BitMapConfig.xml");
        lis = new FileInputStream("src/test/resources/isoTestFile");
        while (true) {
            ISOMsg isoMsg = new ISOMsg();
            isoMsg.setPackager(packager);
            isoMsg.unpack(lis);
            ISOBitMap bitmap = (ISOBitMap) isoMsg.getComponent(-1);
            System.out.println("bitmap.getValue::" + bitmap.getValue()); 
            //or isoMsg.dump(System.out,"");
        }
    } catch (EOFException e) {
        //assume we just ended the stream
    } catch (Exception e) {
        e.printStackTrace();
    } 


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

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