0

I converted the ebcdic input to ascii using this code using apache camel netty..

How to convert binary input to ascii? I tried with all the available charsetutil but its not working..

Any suggestions or answers available...

import java.beans.Encoder;


import org.apache.camel.main.Main;
import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.jboss.netty.handler.codec.frame.LengthFieldPrepender;
import org.jboss.netty.handler.codec.string.StringDecoder;
import org.jboss.netty.handler.codec.string.StringEncoder;
import org.jboss.netty.util.CharsetUtil;

/**
 * Starting point for application
 *  @author SubramaniMohanam
 */
public class MainApp {

    /**
     *  Main method
     *  Encoders and decoders are added here
     *  Route builders are added
     */

    @SuppressWarnings("deprecation")
    public static void main(String... args) throws Exception {
        Main main = new Main();
        main.enableHangupSupport();
        System.out.println("main started ...");


        main.bind("decoder", new LengthFieldBasedFrameDecoder(40, 0, 1,0,0));
        main.bind("decoder", new LengthFieldBasedFrameDecoder(1024, 4, 2,0,17));



        main.bind( "stringEncoder", new StringEncoder("Cp1047"));
        main.bind("stringDecoder", new StringDecoder("Cp1047"));

        main.addRouteBuilder(new StationRouteBuilder());

        main.run(args);
    }
}
madz
  • 168
  • 2
  • 11

1 Answers1

1

I guess that your question is, how to decode EBCDIC binary data to ASCII data? If this is the case, have a look at Converting EBCDIC to ASCII in java and write your own Camel decoder. More information about encoders/decoders can be found here: Can someone better explain Decoders/Encoders?

That said, all encoders/decoders should have a unique binding name (you used "decoder" twice).

Community
  • 1
  • 1
Peter Keller
  • 7,526
  • 2
  • 26
  • 29