I'm trying to create an Android app able to upload and download PDF files to a server, I've already included in my code a method able to download a PDF from an URL such as "http://www.aaaa.com/myfile.pdf" and display it by using intent. But I want to know if there is a way to encode a Pdf into a byte array and viceversa decode a byte array to PDF file (I'm using mongoDB) Thanks to everyone :)
import java.nio.file.*;
Path pdfFilePath = Paths.get("/file/path/your_file.pdf");
// Read file to byte array
byte[] pdfByteArray = Files.readAllBytes(pdfFilePath );
// Write byte array to file
Files.write(pdfFilePath , pdfByteArray);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With