hey guys, is it possible to access `resources` fol...
# ktor
f
hey guys, is it possible to access
resources
folder via
java.io.File
when I run the app locally it works, but when I build the fatJar, this Folder is not available and an exception is thrown, what I’m doing wrong?
Copy code
private val tempMailDirectory = Paths.get("").toAbsolutePath().toString() + "/src/main/resources/blacklisted_domains"
m
I think you do not need even
java.io.File
I have in my backend like this
Copy code
javaClass.classLoader?.getResource("YOUR_PATH")?.readText()?.let{
// do your stuff
}
f
@Mustafa Ozhan thank you, that solves the problem, kinda hacky way but it works
👊 1
c
That’s not a hacky way - that’s the way you access resourses in a jar package 😉 https://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html
❤️ 2
if you need a
File
you can use the
URL
retuned from
ClassLoader#getResource(String name)
f
TIL @Chrimaeon thanks