Skip to content

Instantly share code, notes, and snippets.

@desiderantes
Created July 16, 2018 16:26
Show Gist options
  • Save desiderantes/3702f2c73cb16243b33ea827eee094fe to your computer and use it in GitHub Desktop.
Save desiderantes/3702f2c73cb16243b33ea827eee094fe to your computer and use it in GitHub Desktop.
val result = StringBuffer()
val HEX_CHARS = "0123456789ABCDEF".toCharArray()
java.io.File("YOUR PATH HERE").forEachBlock { buffer,read->
buffer.forEach {
val octet = it.toInt()
val firstIndex = (octet and 0xF0).ushr(4)
val secondIndex = octet and 0x0F
result.append(HEX_CHARS[firstIndex])
result.append(HEX_CHARS[secondIndex])
}
}
System.out.println(result.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment