Skip to content
Advertisement

Tag: resources

Problem resolving an android.content.res.Resources error

I understand that this error has been addressed severally and I’ve checked most of them like Android: android.content.res.Resources$NotFoundException: String resource ID #0x5, android.content.res.Resources$NotFoundException: String resource ID to see if I could find a solution to my problem but I couldn’t and most of them are hard to understand. I can’t tell if my code is an int/string so I don’t

How to get .jar resources path?

I’m using a custom method to get pictures from the resources/ folder. The hardcoded path works well when programming during production (src/main/resources/). However when delivering, I would need to make this path relative to the .jar root. So I made this. The printed path is valid and points to the corresponding picture. However, the program raises an IOException. Why can’t

Proper way to close an AutoCloseable

What is the most reliable pattern to follow when closing an OutputStream, ServerSocket, or other object that implements the AutoCloseable interface? Should I use try-catch-finally? Or a shutdown hook. Answer The correct way to use an AutoCloseable instance is with a try-with-resources block, so the resource is reliably closed even if an exception is thrown. Like this: You can also

Read directory inside JAR with InputStreamReader

So, this question has been asked a million times i believed and I’ve been reading them for a couple of hours and trying several options given by some people but none of them work for me. I want to list all the files inside a directory inside the application’s JAR, so in IDE this works: That gives me all the

open resource with relative path in Java

In my Java app I need to get some files and directories. This is the program structure: guiclass loads the resourcesloader class which will load my resources (directory and file). As to the file, I tried in order to get the real path, but this way does not work. I have no idea which path to use for the directory.

Advertisement