mbien commented on code in PR #149: URL: https://github.com/apache/netbeans-mavenutils-nbm-maven-plugin/pull/149#discussion_r1497167259
########## nbm-maven-plugin/src/main/java/org/apache/netbeans/nbm/CreateWebstartAppMojo.java: ########## @@ -616,66 +616,44 @@ private File copyLauncher( File standaloneBuildDir, File builtInstallation ) File jnlpStarter = new File( builtInstallation.getAbsolutePath() + File.separator + "harness" + File.separator + "jnlp" + File.separator + "jnlp-launcher.jar" ); - // buffer so it isn't reading a byte at a time! - InputStream source = null; - FileOutputStream outstream = null; - try - { - if ( !jnlpStarter.exists() ) - { - source = getClass().getClassLoader().getResourceAsStream( - "harness/jnlp/jnlp-launcher.jar" ); - } - else - { - source = new FileInputStream( jnlpStarter ); - } - File jnlpDestination = new File( + // buffer so it isn't reading a byte at a time! + File jnlpDestination = new File( standaloneBuildDir.getAbsolutePath() + File.separator + "jnlp-launcher.jar" ); - - outstream = new FileOutputStream( jnlpDestination ); + try ( InputStream source = ( !jnlpStarter.exists() ? + getClass().getClassLoader().getResourceAsStream("harness/jnlp/jnlp-launcher.jar" ) : + new FileInputStream( jnlpStarter )) ; + FileOutputStream outstream = new FileOutputStream( jnlpDestination ); ) + { IOUtil.copy( source, outstream ); return jnlpDestination; - } - finally - { - IOUtil.close( source ); - IOUtil.close( outstream ); - } + } } private void filterCopy( File sourceFile, String resourcePath, File destinationFile, Properties filterProperties ) throws IOException { // buffer so it isn't reading a byte at a time! - Reader source = null; - Writer destination = null; - try + + InputStream instream; + if ( sourceFile != null ) + { + instream = new FileInputStream( sourceFile ); + } + else + { + instream = getClass().getClassLoader().getResourceAsStream( resourcePath ); + } + + FileOutputStream outstream = new FileOutputStream( destinationFile ); + + try ( Reader source = new BufferedReader( new InputStreamReader( instream, "UTF-8" ) ); Writer destination = new OutputStreamWriter( outstream, "UTF-8" ); ) { Review Comment: ```java try (Reader source = new BufferedReader(new InputStreamReader(instream, "UTF-8")); Writer destination = new OutputStreamWriter(outstream, "UTF-8")) { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists