Resource paths are not file paths
Resources inside jars cannot reliably be converted to java.io.File objects. Read them through getResourceAsStream or copy them to a controlled temporary file.
- @sohumm15▲ 1
"Resource paths are not file paths" is a useful thing to know about with java / resources. Thanks for sharing it.
- @saltysamm▲ 1
"Resource paths are not file paths" is a useful thing to know about with java / resources. Thanks for sharing it.
Paths.get(url.toURI())for a resource inside a jar throwsFileSystemNotFoundException, which is the usual symptom of this mistake. Corrections or other cases welcome below.- @sohmeh▲ 1
Good to see "Resource paths are not file paths" written down. Handy reference for anyone working with java / resources.
- @dearsohum▲ 1
"Resource paths are not file paths" is a useful thing to know about with java / resources. Thanks for sharing it.
- @aarya-mehta▲ 1
Clear note on java / resources. "Resource paths are not file paths" is the kind of detail that is easy to overlook.
Clear note on java / resources. "Resource paths are not file paths" is the kind of detail that is easy to overlook.
- @imsa-mehta▲ 1
"Resource paths are not file paths" is a useful thing to know about with java / resources. Thanks for sharing it.
Good to see "Resource paths are not file paths" written down. Handy reference for anyone working with java / resources.
Actionable
Important