Hi All,
Wondering if a PDF can be read and the content inside it can be written into a txt file. Fow now i'm just giving a sys out. Below is my attempt,
sry if the question is silly.
Freddie
Wondering if a PDF can be read and the content inside it can be written into a txt file. Fow now i'm just giving a sys out. Below is my attempt,
Code:
public static void main(String args[]) throws IOException {
FileInputStream fis = new FileInputStream(new File("c:\\zoutput.pdf"));
ByteArrayOutputStream docContents = new ByteArrayOutputStream();
byte[] buffer = new byte[16384];
int bytesRead = fis.read(buffer);
while (bytesRead > -1) {
docContents.write(buffer, 0, bytesRead);
bytesRead = fis.read(buffer);
}
System.out.println(docContents.toString("UTF-8"));
}
Freddie
Comment