I have storaged in file in my database (format byte[]) and the name and format of the file.
Now i convert my bytearray into an InputStream. How can i recreated the specific file with this InputStream, which was saved in the database before? For example, a PDF document must be a PDF document and a txt file muste be a txt file.
I work with jsf and this is my current code:
Dto currentDto = //code to get the file from the database
final FacesContext facesContext = FacesContext.getCurrentInstance();
final ExternalContext externalContext = facesContext.getExternalContext();
final HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
InputStream inputStream = new ByteArrayInputStream(currentDto.getFileBytes());
OutputStream outputStream = response.getOutputStream();