将bytearrayinputstream扔到javascript文件

时间:2018-12-13 05:06:45

标签: javascript java angularjs

Java代码:

ByteArrayInputStream streamInput =  object.getContent();
...
// what should i do :)
...
Map<String, Object> returnData = new HashMap<>();
returnData.put("streamFile", streamFile);
return new ResponseEntity<Map<String, Object>>(returnData, HttpStatus.OK);

我有ByteArrayInputStream,我希望将此ByteArrayInputStream转换为javascript文件。我已经这样做了:

int n = streamInput.available();
byte[] bytes = new byte[n];
streamInput.read(bytes, 0, n);
String stringFile = new String(bytes, StandardCharsets.UTF_8);

...
returnData.put("streamFile", stringFile);
        return new ResponseEntity<Map<String, Object>>(returnData, HttpStatus.OK);

我得到了字符串,但是我不知道如何将其转换为文件。有人知道吗?

0 个答案:

没有答案