I am trying to get ressource of SQL file in src / main / resources.
I managed to get the file with this:
String sqlFileName = "query.sql"; URL url = MyClass.class.getClassLoader().getResource(sqlFileName);
But no, if there is one quote in sqlFileName
String sqlFileName = "John query.sql"; URL url = MyClass.class.getClassLoader().getResource(sqlFileName);
getResource returns null because it cannot find my resource when there is an apostrophe. I tried several methods to avoid my separate quote, such as \ 'and', and none of them worked.
I expect to get a url with getResource similar to this:
C:\Projects\ProjectA\src\main\resources\queries\John query.sql
source share