Java在Oracle中的Hextoraw功能相等
您好,我想要 Oracle 中 HEXTORAW 函数的 Java 等价物。在 oracle 中,您可以使用:
SELECT hextoraw(to_char(ascii('z'))) from DUAL;
生成 0122 或使用
SELECT hextoraw(to_char(ascii('C'))) from DUAL;
生成 67 我在java中找到的所有方法都不将左0添加到99以上的ascii代码中,我该如何解决这个问题? 这是我使用的两种方法:
String key="zs01C";
IntStream intStream = key.codePoints();
String rawKey = intStream.mapToObj(c->Integer.toString(c)).collect(Collectors.joining());
System.out.println("Method1: "+rawKey);
intStream = key.codePoints();
String rawKey2 = intStream.mapToObj(c->String.format("%2s", c).replace(' ', '0')).collect(Collectors.joining());
System.out.println("Method2: "+rawKey2);
Hi I want the java equalent of HEXTORAW Function In Oracle .in oracle you can use :
SELECT hextoraw(to_char(ascii('z'))) from DUAL;
that generates 0122 or use
SELECT hextoraw(to_char(ascii('C'))) from DUAL;
which generates 67
all methods that i found in java dont add left 0 to the ascii codes above 99 how can i solve this?
thease are 2 of methods that i used:
String key="zs01C";
IntStream intStream = key.codePoints();
String rawKey = intStream.mapToObj(c->Integer.toString(c)).collect(Collectors.joining());
System.out.println("Method1: "+rawKey);
intStream = key.codePoints();
String rawKey2 = intStream.mapToObj(c->String.format("%2s", c).replace(' ', '0')).collect(Collectors.joining());
System.out.println("Method2: "+rawKey2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
十六进制字符串通常是字节数组大小的两倍,所以你可以尝试这个
Hex string usually double the size of byte array, so you can try this