View Directory Image

1

I need to display an image in the application which is in the application's external directory. I am using it as follows, but image is not displayed. It looks as if the path is incorrect.

public StreamedContent getImagem() {
        DefaultStreamedContent defaultStreamedContent = null;
        try {
            String caminhoArquivoCompleto = getCaminhoArquivoCompleto();
            File file = new File(caminhoArquivoCompleto);
            ByteArrayInputStream imagemStream = new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
            defaultStreamedContent = new DefaultStreamedContent(imagemStream, "image/png");
        } catch (IOException io) {
            System.out.println(io.getCause());
        }
        return defaultStreamedContent;
    }


<p:graphicImage value="#{arquivo.imagem}" width="50" height="50" cache="false" />
    
asked by anonymous 24.01.2017 / 17:52

0 answers