gpt4 book ai didi

jsf - UT010006 : Cannot call getWriter(), getOutputStream() 已调用

转载 作者:行者123 更新时间:2023-12-04 17:48:49 38 4
gpt4 key购买 nike

<分区>

我在尝试下载文件时收到此错误消息:

无法处理异常!:java.lang.IllegalStateException:UT010006:无法调用 getWriter(),getOutputStream() 已调用。

文件已下载但没有扩展名。所以浏览器问我应该使用什么程序来阅读它。

这是我的下载代码:

    InputStream fileIs = null;
OutputStream output = null;
try {
ExternalContext externalContext = getContext().getExternalContext();
externalContext.responseReset();
externalContext.setResponseContentType(fileToDownload.getMetadata().getMimeType());
externalContext.setResponseContentLength(fileToDownload.getMetadata().getTaille().intValue());
externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"" + fileToDownload.getMetadata().getFileName() + "\"");

output = externalContext.getResponseOutputStream();
Response repGetFile = ClientBuilder.newClient()
.target(fileToDownload.getMetadata().getFileURL())
.request().header("Authorization", "Bearer bearercode")
.get();

fileIs = repGetFile.readEntity(InputStream.class);
int readBytes;
byte[] buffer = new byte[1024];
while((readBytes = fileIs.read(buffer)) > 0){
output.write(buffer, 0, readBytes);
}
output.flush();

} catch (IOException ex) {
LOG.log(Level.SEVERE, null, ex);
} finally{
try {
fileIs.close();
output.close();
} catch (IOException ex) {
LOG.log(Level.INFO, null, ex);
}
}

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com