我在JpaRepository中定义了一个JPA查询:
List<Object[]> getDoc ();其中一列,如果是BLOB type
但当我这么做的时候:
System.out.println("Content Type -> " + obj[1].getClass());
System.out.println("Content -> " + obj[1]);我得到了:
Content Type -> class [B
Content -> [B@73e73b8e我不知道怎么把它转换成字符串
发布于 2021-02-26 19:24:33
这意味着您的obj[1]是一个字节数组,这正是blob应该是的。
要将其转换为字符串,需要指定编码。假设数据是按照UTF-8编码的,那么就是
String s = new String((byte[]) obj[1], StandardCharsets.UTF_8)https://stackoverflow.com/questions/66384883
复制相似问题