Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | package br.gov.al.saude.test.util; |
| 2 | |||
| 3 | import java.io.File; |
||
| 4 | import java.io.FileInputStream; |
||
| 5 | import java.io.IOException; |
||
| 6 | |||
| 7 | import org.apache.commons.io.IOUtils; |
||
| 8 | import org.springframework.core.io.DefaultResourceLoader; |
||
| 9 | |||
| 10 | public class FileUtil { |
||
| 11 | |||
| 12 | public static byte[] getConteudoArquivoImagem(String diretorio, String nomeFoto) { |
||
| 13 | try { |
||
| 14 | DefaultResourceLoader defaultResourceLoader = new DefaultResourceLoader(); |
||
| 15 | File file = defaultResourceLoader.getResource(diretorio + nomeFoto).getFile(); |
||
| 16 | FileInputStream fis = new FileInputStream(file); |
||
| 17 | byte[] conteudo = IOUtils.toByteArray(fis); |
||
| 18 | fis.close(); |
||
| 19 | return conteudo; |
||
| 20 | } catch (IOException e) { |
||
| 21 | e.printStackTrace(); |
||
| 22 | return null; |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | } |