I have a String in the following format: -----BEGIN MESSAGE-----, followed by a variable length encrypted session key, followed by a newline, followed by an encrypted message, followed by a newline, followed by a digital signature, followed by -----END MESSAGE-----.
-----BEGIN MESSAGE-----
SNyeWtz8QD8AKdioMG11wu7U6gG2wD9tekvVrx6VYW+6oJj4Wl8NE+7i5MHbu4Au
+vN1Z886lOWka7ekgPF8N7t9MpiFo2pBPHuFcOsaY5ETYuEyk5gaX7BYP7qT6wKG
BRILmX6DblWqGxG2tKs/AdcHDqQ5QBXrP03uhN68wgo=
U2FsdGVkX18gtpQSqyH4H5242SZzcZrb0oH7FWw7/MSCxo7h7BVaesZV2N38sr9y
kVr+wabiNn4RfAB4nNi9gAZHQLok4uxRMALGF2kZk2zpVNPQo6jcdz85fy68gylX
OCQIIdk8JPIwxzHfVvRZqNHDRADZRlNHUMYScjRPU+DB8avghYAVKMJhLgA/2Tdp
a59uBMBg/yB1yqA5FivxPzOhq92Y4nZuP1R9/yGE9O8K
-----END MESSAGE-----
What is the best way to parse out the three pieces of information (the session key, encrypted message, and digital signature)?
I tried using the Scanner class but I coudln't figure out what to use as the delimeter. I also tried using the Pattern class, but couldn't figure that method out either. Thank you!