how can we read a .pdf file in java
read a file
Collapse
X
-
Originally posted by litunhow can we read a .pdf file in java
But maybe you want tor rephrase your question, because you want to display it on screen in java, or convert it to different format, or copy it? I am just curious about your question, because you mention ".pdf" which has nothing to do with "reading" the file.
here is how to read a file:
Code:File sourceFile = new File(sourceFileName); if (! sourceFile.exists()) throw new IOException("[ERROR ]: no such source file: " + sourceFileName); if (! sourceFile.isFile()) throw new IOException("[ERROR]: can't copy directory: " + sourceFileName); if (! sourceFile.canRead()) throw new IOException("[ERROR]: source file is unreadable: " + sourceFileName); FileInputStream sourceStream = null; byte[] buffer = new byte[file.length()]; sourceStream = new FileInputStream(sourceFile); int bytesRead = sourceStream.read(buffer);
-
Originally posted by litunhow can we read a .pdf file in javaComment
-
Originally posted by litunhow can we read a .pdf file in javaComment
-
Originally posted by hsnhi
have even tried to read a PDF file before you ask here.
i think it should work normally. because you can read any type of file by java and its classes.
you can read html, word documents, in,txt, and so on. why will it stop at PDF
Good Luck
hsnComment
Comment