Skip to content

Instantly share code, notes, and snippets.

@marcosbarker
Last active April 11, 2023 16:04
Show Gist options
  • Save marcosbarker/f7b9149e4be6fb7ff1333d8bc7161e09 to your computer and use it in GitHub Desktop.
Save marcosbarker/f7b9149e4be6fb7ff1333d8bc7161e09 to your computer and use it in GitHub Desktop.
Codifica PDF em Base64 puro texto
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
@marcosbarker
Copy link
Author

marcosbarker commented Apr 11, 2023

  • Explicacao do codigo

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment