在Java中将bytea从Postgres转换为String

时间:2013-10-18 12:02:10

标签: java string hibernate encoding bytea

好吧,我在postgres中有一个类型为bytea的列,有很多字符并且工作正常,但是当我使用hibernate来捕获这些数据时,我从原始值中获得了许多值的差异。

原始值为:“E02DR0207BR000000105544 FS60”  但回报是:37,51,49,51,54,52,52,53,50,51,48,51,50 ......  返回应以'69'开头,因为'69'在ASCII表中是'E'。

编辑1:

我正在以这种方式将byte []转换为String:

StringBuilder s = new StringBuilder();

        for(byte l : this.linha){
            s.append((char)l);
        }
        return s.toString();          

编辑2:

The original LINE: 
E16DR0209BR000000187080 FS600               330087420066670000000000000000CN20120901124443

The byte line in JAVA:
%30314452303230394252303030303030313837303830204543462d494620444152554d41204155544f4d4143414f20202020465336303020202020202020202012090120120901313035303020202020323030393039313531313233333030303430343034393439373030343334324d46443030303335343030303335353230313230393031323031323039303130382e30322e37364143313730342030312e30302e3030

0 个答案:

没有答案