All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jtransc.vfs.FileExt.kt Maven / Gradle / Ivy

package com.jtransc.vfs

import java.io.File

operator fun File.get(name: String) = File(this, name)

fun File.ensureExists() {
	if (!this.exists() && !this.mkdir()) throw RuntimeException("Failed to create folder: ${this.absolutePath}")
}

fun ClassLoader.getResourceBytes(name: String): ByteArray {
	return this.getResourceAsStream(name).use { stream ->
		stream.readBytes(stream.available())
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy