private void initComponents()
{
this.setTitle("Visualização de Arquivo PDF: "+this.nomeArquivo);
this.setResizable(true);
this.setLayout(new BorderLayout());
try
{
pdfViewer = new Viewer();
this.add(pdfViewer, BorderLayout.CENTER);
}
catch (Exception ex)
{
Logger.getLogger(ExibePDF.class.getName()).log(Level.SEVERE, null, ex);
}
InputStream input=null;
try
{
input = new FileInputStream(this.file);
if(input != null)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
// set read buffer size
byte[] rb = new byte[1024];
int ch = 0;
while ((ch = input.read(rb)) != -1)
{
output.write(rb, 0, ch);
}
byte[] b = output.toByteArray();
input.close();
output.close();
ByteArrayInputStream bai= new ByteArrayInputStream(b);
this.pdfViewer.setDocumentInputStream(bai);
this.pdfViewer.renderPage(this.page -1);
bai.close();
}
}
catch (Exception ex)
{
}
try
{
this.pdfViewer.setProperty("Default_Page_Layout", "SinglePage");
this.pdfViewer.setProperty("Default_Zoom_Type", "FitVisibleWidth");
this.pdfViewer.setProperty("Default_Magnification", "100");
this.pdfViewer.activate();
this.pdfViewer.execMenuItem(ViewerCommand.FitWidth_K);
} catch (Exception ex)
{
Logger.getLogger(ExibePDF.class.getName()).log(Level.SEVERE, null, ex);
}
this.setSize(this.largura, this.altura);
this.setLocation(0, 0);
this.setClosable(false);
this.setIconifiable(false);
this.setVisible(true);
}
Bom eu fecho todas a variaveis que trabalham com streams mas continua dando o erro, alguem sabe como realmente liberar a memoria pra que o erro não ocorra ?