Abrir Pdf a partir de um diretório em disco

Pessoal muito bom dia!

Ja pesquisei no forum e vi alguns tópicos sobre o assunto, mas não consegui rodar aqui. :frowning:

Tenho alguns Pdf em um diretório e na minha aplicação preciso abri-lo, mas não estou conseguindo.

Alguem pode da um help?

String path = "C:" + File.separator + "Documents and Settings"
			+ File.separator + "usuario" + File.separator
			+ "Meus documentos" + File.separator + "Apostilas" + File.separator + "25_08_09 01_40_54.pdf";
			
String nomeArquivo = "Relatorio";

File dir = new File(path);

HttpServletResponse response = FacesUtils.getResponse();
response.reset();
response.setContentType("application/force-download");
response.setHeader("Content-Disposition", "attachment;filename=\""+ nomeArquivo + "\";");

como eu faço para pegar o Pdf e jogar para o servlet?

tipo:

response.setContentLength(pdf.length);
response.getOutputStream().write(pdf, 0, pdf.length);

VlW!

Olá!

O arquivo está no servidor, certo?!

vai estar qdo aplicação tiver pronta. Hj esta na minha maquina. Num diretório qqer.

Galera Resolvido!!!

Pesquisando mais no forum vi o post do Andrerios. Para o meu caso ficou assim:

try {
			
			byte[] arquivo = null;

			File dir = new File(pdf.getPath());
			
			try {
				arquivo = fileToByte(dir); 				
			} catch (Exception e) {
				e.printStackTrace();
			}
			
			HttpServletResponse response = FacesUtils.getResponse();
			response.reset();
			response.setContentType("application/pdf");
			response.setHeader("Content-Disposition", "attachment;filename=\""+ pdf.getDescricao() + "\";");
	        response.setContentLength(arquivo.length);  
			response.getOutputStream().write(arquivo, 0, arquivo.length);
			FacesContext.getCurrentInstance().responseComplete();

		} catch (Exception e) {
			e.printStackTrace();
		}

public static byte[] fileToByte(File pdf) throws Exception {
		FileInputStream fis = new FileInputStream(pdf);
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		byte[] buffer = new byte[8192];
		int bytesRead = 0;
		while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
			baos.write(buffer, 0, bytesRead);
		}
		return baos.toByteArray();
	}  

vlw galera!