0
我無法將索引的字節序列轉換爲以utf-8編碼的字符串。如何在Scala中有效地將IndexedSeq [Byte]轉換爲utf-8字符串
scala> val x : IndexedSeq[Byte] = IndexedSeq(64.toByte, 64.toByte, 64.toByte)
scala> x.mkString
res2: String = 748464
現在我可以使它工作,通過轉換爲數組,然後構建一個新的字符串像這樣;
scala> new String(x.toArray)
res3: String = [email protected]
但分配和複製兩次似乎是一個矯枉過正。
有沒有更好的方法?