Created
July 13, 2015 09:37
-
-
Save jonashackt/a5605ce850dc3094432b to your computer and use it in GitHub Desktop.
Decode and write Base64-encoded ISO_8859_1 String to Pdf-File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void decodeAndWriteBase64Pdf() throws Exception { | |
System.out.print("Enter base64EncodedPdfAsIsoString (e.g. from SOAP-Call):"); | |
Scanner s = new Scanner(System.in); | |
String base64EncodedPdfAsIsoString = s.nextLine(); | |
s.close(); | |
byte[] decodedPdf = Base64.getDecoder().decode(base64EncodedPdfAsIsoString); | |
writeFileInClasspath(decodedPdf); | |
} | |
private static void writeFileInClasspath(byte[] base64EncodedPdfAsIsoString) throws Exception { | |
try ( OutputStream out = Files.newOutputStream( Paths.get( "foo2.pdf" ))) { | |
out.write(base64EncodedPdfAsIsoString); | |
} | |
catch ( IOException exception) { | |
throw new Exception("Problem beim Schreiben der Datei: " + exception.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment