File privateKeyFile = new File(this.getClass().getClassLoader().getResource("privateKey").getFile());
successfully gives me a keyFile. If I now list the path with:
privateKeyFile.toPath()
debug successfully shows me a path to the file:
file:/Users/me/.m2/repository/com/xx/xyz/abc/encryption/1.0/encryption-1.0.jar!/privateKey
--
However, as soon as I try and read that file with
Files.readAllBytes(privateKeyFile.toPath())
I get
Method threw 'java.nio.file.NoSuchFileException' exception.
This is really confusing, and I've tried changing the getResource()
to various things like getResource("/privateKey");
- yet that errors a lot sooner, actually a NPE right when trying to create a new File()
, so the file MUST exist as I've shown above??