Am getting base64 encoded data as String
format. Am trying to decode the base64 and want to download as a file. I have commented the below few lines of code, where am getting error out of those line.
Am not sure how to decode the data.
String contentByte=null;
for (SearchHit contenthit : contentSearchHits) {
Map<String, Object> sourceAsMap = contenthit.getSourceAsMap();
fileName=sourceAsMap.get("Name").toString();
System.out.println("FileName ::::"+fileName);
contentByte = sourceAsMap.get("resume").toString();
}
System.out.println("Bytes --->"+contentByte);
File file = File.createTempFile("Testing",".pdf", new File("D:/") );
file.deleteOnExit();
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write(Base64.getDecoder().decode(contentByte)); //getting error on this line
Please find the below compilation error am getting.
The method write(int) in the type BufferedWriter is not applicable for the arguments (byte[])
Am using Java 8 version