Answer the question
In order to leave comments, you need to log in
Is it possible to download a pdf file using Java?
There is a button click handler that writes a specific pdf file (using the iText library). Is it possible to make it so that with the same click, this file is downloaded, for example, to the download folder?
To make it clearer, below is the code that downloads the file by url, you need to implement the same thing, but instead of url - the path to the finished pdf file.
URL website = new URL("https://africau.edu/images/default/sample.pdf");
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream("C:/Downloads/sample.pdf");
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question