【发布时间】:2018-07-22 21:13:26
【问题描述】:
我正在以 String 格式获取 base64 编码数据。我正在尝试解码 base64 并希望作为文件下载。我已经注释了以下几行代码,这些代码在哪里出错了。
我不确定如何解码数据。
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
请找出下面的编译错误。
The method write(int) in the type BufferedWriter is not applicable for the arguments (byte[])
我使用的是 Java 8 版本
【问题讨论】:
-
什么错误?请发布您在问题中遇到的错误