Is this possible to convert EBCDIC Comp-3 file to ASCII file values using java?

I am trying to convert the EBCDIC COMP-3 fields to ASCII values but which is not working.But Binary COMP-3 fields could be converted to ASCII values.Please help me to understand is this possible or not? Even using any other java library is ok for me.I tried and searched may but no concrete answer I could see.


In my previous one binary should be the one which will work.This what I received as answer but there was no clarity about EBCDIC COMP-3.


001700 01 EMP-RECORD.                                                           
001900        10  EMP-NO                     PIC 9(10).                         
002000        10  EMP-NAME                   PIC X(30).                         
002100        10  EMP-ADDRESS                PIC X(30).                         
002200        10  EMP-SALARY                 PIC S9(8)V9(2) COMP-3.             
002200        10  EMP-ZIPCODE                PIC 9(4).                          

BINARY COMP-3 file: could be converted

  ËÍ>ÁÁ% ,Í_/Ê Ê                Â/>Å/%?ÊÁ                        Á~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ¢|ëá&ç                        ïçñèá ãñá<à                     ÊÊ>     

EBCDIC COMP-3:not able to convert

0000001001suneel kumar r                city                       e¡5671   


public static void main(String args[]) throws Exception {
    String salesFile = "empcompnewbinary.txt";
    String copybookName = "EMPCOPYBOOK.txt";
    AbstractLine saleRecord;

    int fileStructure = Constants.IO_FIXED_LENGTH;
    CobolIoProvider ioProvider = CobolIoProvider.getInstance();
    AbstractLineReader reader = ioProvider.getLineReader(fileStructure, Convert.FMT_MAINFRAME,
            CopybookLoader.SPLIT_NONE, copybookName, salesFile);

    while ((saleRecord = != null) {
        System.out.print(saleRecord.getFieldValue("EMP-NO").asString() + "-"
                + saleRecord.getFieldValue("EMP-NAME").asString() + "-"
                + saleRecord.getFieldValue("EMP-ADDRESS").asString() + "-"
                + saleRecord.getFieldValue("EMP-SALARY").asDouble() + "-"
                + saleRecord.getFieldValue("EMP-ZIPCODE").asString());


  • There is no such thing as an "EBCDIC COMP-3 field", and it has no equivalent in ASCII code points. It is a binary format. So understand you have a record mixed of character and binary formats.

    Comp-3 is packed decimal. It can vary a bit on different machine architectures as to where they put the sign nibble and whatnot, but it is a binary format, so any attempt to convert it using character set rules will always fail.

    The easiest way to deal with this, by far, is to convert any packed decimal data to a display format, made up of characters. So instead of x'0123456C', you actually convert that to c'01234.56', and then your standard EBCDIC to ASCII conversion will work fine.