From 3c82d1e54ef86d01db1678f74fe0fe78b65e9aa8 Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Mon, 16 May 2005 18:06:23 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@192 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/siprp/ficha/ExamePDF.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/trunk/siprp/ficha/ExamePDF.java b/trunk/siprp/ficha/ExamePDF.java index 1085615c..a55ab132 100644 --- a/trunk/siprp/ficha/ExamePDF.java +++ b/trunk/siprp/ficha/ExamePDF.java @@ -128,8 +128,8 @@ public class ExamePDF { public void print( byte []pdf ) throws Exception { - - FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf" ); + long time = System.currentTimeMillis(); + FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ); fos.write( pdf ); fos.close(); System.out.println( "File saved." ); @@ -137,15 +137,18 @@ public class ExamePDF { if( System.getProperty( "os.name" ).startsWith( "Windows" ) ) { //System.out.println( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); - proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); + proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf\"" ); proc.waitFor(); - new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf" ).delete(); + if( !new File( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" ).delete() ) + { + System.err.println( "File: report_ficha" + time + ".pdf - NOT DELETED" ); + } } else { //System.out.println( "/usr/bin/open \"" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf\"" ); try{ - proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha.pdf" } ); + proc = Runtime.getRuntime().exec( new String[]{"/usr/bin/open", "" + System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + "report_ficha" + time + ".pdf" } ); } catch( Exception ex ) {