2424import java .io .OutputStream ;
2525import java .io .InputStream ;
2626
27- import org .apache .commons .io .IOUtils ;
2827import org .apache .xmlgraphics .ps .dsc .DSCException ;
2928import org .apache .xmlgraphics .ps .dsc .tools .PageExtractor ;
3029
@@ -44,20 +43,13 @@ public class DSCProcessingExample1 {
4443 * @throws IOException In case of an I/O error
4544 */
4645 public void extractPages (File srcFile , File tgtFile , int from , int to ) throws IOException {
47- InputStream in = new java .io .FileInputStream (srcFile );
48- in = new java .io .BufferedInputStream (in );
49- try {
50- OutputStream out = new java .io .FileOutputStream (tgtFile );
51- out = new java .io .BufferedOutputStream (out );
52- try {
53- PageExtractor .extractPages (in , out , from , to );
54- } catch (DSCException e ) {
55- throw new RuntimeException (e .getMessage ());
56- } finally {
57- IOUtils .closeQuietly (out );
58- }
59- } finally {
60- IOUtils .closeQuietly (in );
46+ try (InputStream fin = new java .io .FileInputStream (srcFile );
47+ InputStream in = new java .io .BufferedInputStream (fin );
48+ OutputStream fout = new java .io .FileOutputStream (tgtFile );
49+ OutputStream out = new java .io .BufferedOutputStream (fout )) {
50+ PageExtractor .extractPages (in , out , from , to );
51+ } catch (DSCException e ) {
52+ throw new RuntimeException (e .getMessage ());
6153 }
6254 }
6355
0 commit comments