Reading a Private Key from PEM file

Hi All,

I’m trying to read a private key from a PEM file but getting the below error.

"j.s.s.InvalidKeySpecException: java.security.InvalidKeyException: invalid key format’, forwarding to the next one".

I’m using the below function to read the pem file but looks like it’s not reading the entire file.

Files.readAllBytes(Paths.get(filename))

The output is as below.

Simulation Functions started…
Success-1
Success-3
[B@70602010Success-2 12:11:37.717 [ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - ‘hook-2’ crashed with ‘j.s.s.InvalidKeySpecException: java.security.InvalidKeyException: invalid key format’, forwarding to the next one

Hi All,

Please execuse my lack of knowledge on scala.

I’m reading a file content as a string using

Source.fromFile(filename).getLines.mkString

I want the new line to be replaced with \n character.

Please can you suggest me if there is a way to read that way.

Thanks,
Prash.

https://www.scala-lang.org/api/2.12.2/scala/collection/immutable/List.html#mkString(sep:String):String

Thank you !!!

This issue is resolved. Thanks !!!