com.jtransc.io.classutils.kt Maven / Gradle / Ivy
package com.jtransc.io
import java.io.IOException
fun Class.readBytes(): ByteArray {
val filePath = this.name.replace('.', '/') + ".class"
val stream = this.classLoader.getResourceAsStream(filePath) ?: throw IOException("Can't find class $filePath")
return stream.readBytes()
}