blob: 8792e042480375cb5e7e5bd06efc16d6a3e443f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package moe.yuuta.workmode.utils
object ByteArraySerializer {
fun serialize(array: ByteArray): String {
val builder = StringBuilder()
array.toList().stream()
.forEachOrdered {
builder.append(it)
builder.append(',')
}
var result = builder.toString()
result = result.substring(0, result.length - 1)
return result
}
fun deserialize(value: String): ByteArray {
val list = value.split(',').toList()
var array = ByteArray(0)
list.stream()
.forEachOrdered {
array = array.plus(it.toByte())
}
return array
}
}
|