I have to consume as rest api API(/getconstomerList) from my java code that returns a pdf file. I need to read the PDF file and convert it to String.
I tried doing this with tika
BodyContentHandler handler = new BodyContentHandler(10 * 1024 * 1024);
Metadata metadata = new Metadata();
URL url = new URL("http://" + hostName + uri);
BufferedInputStream inputstream = new BufferedInputStream(url.openStream());
Parser parser = new AutoDetectParser();
parser.parse(inputstream, handler, metadata, pcontext);
return handler.toString();
But this code keep returning me empty response, I am not sure what is wrong or if there is any other way to do this. Please help.