骆驼网络中的二进制编码器

时间:2014-11-28 04:19:00

标签: apache-camel netty

我使用apache camel netty使用此代码将ebcdic输入转换为ascii ..

如何将二进制输入转换为ascii?我尝试了所有可用的charsetutil但它不起作用..

任何可用的建议或答案......

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);
    }
}

1 个答案:

答案 0 :(得分:1)

我猜你的问题是,如何将EBCDIC二进制数据解码为ASCII数据?如果是这种情况,请查看Converting EBCDIC to ASCII in java并编写自己的Camel解码器。有关编码器/解码器的更多信息,请访问:Can someone better explain Decoders/Encoders?

也就是说,所有编码器/解码器都应该有一个唯一的绑定名称(你使用"decoder"两次)。