0
我正在使用JAVA的C#webapi。 API方法返回一个文件字节数组。我可以读取java中的字节数组响应,但是当我尝试将其转换为文件时,它会将完整的字符串写入文件中。将api httpresponse bytearray转换为文件
下面是我使用的代码:
HttpResponse response=...
byte[] content = EntityUtils.toByteArray(response.getEntity());
File fileToWriteTo = new File("abc.docx");
FileUtils.writeByteArrayToFile(fileToWriteTo, content);
下面是文件的生成的屏幕截图: DOCX file screenshot
下面是提琴手响应截图: Fiddler response screenshot
感谢您的回复。你的建议对我有用。 –