Last active
April 11, 2023 16:04
-
-
Save marcosbarker/f7b9149e4be6fb7ff1333d8bc7161e09 to your computer and use it in GitHub Desktop.
Codifica PDF em Base64 puro texto
This file contains hidden or 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
import java.util.Base64; | |
import java.io.File; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardOpenOption; | |
String filePath = "pdfTeste.pdf"; | |
File file = new File(filePath); | |
byte[] bytes = Files.readAllBytes(file.toPath()); | |
String encodedFile = Base64.getEncoder().encodeToString(bytes); | |
String outputFilePath = "base64purinhoPurinho.txt"; | |
Files.write(Paths.get(outputFilePath), encodedFile.getBytes(), StandardOpenOption.CREATE); | |
return encodeFile |
Author
marcosbarker
commented
Apr 11, 2023
•
- Explicacao do codigo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment