private boolean isDotnetPath ( ) { final String [ ] args = new String [ 2 ] ; args [ 0 ] = "dotnet" ; args [ 1 ] = "--version" ; final ProcessBuilder pb = new ProcessBuilder ( args ) ; try { final Process proc = pb . start ( ) ; final int retCode = proc . waitFor ( ) ; if ( retCode == 0 ) { return true ; } final byte [ ] version = new byte [ 50 ] ; final int read = proc . getInputStream ( ) . read ( version ) ; if ( read > 0 ) { final String v = new String ( version , UTF_8 ) ; if ( v . length ( ) > 0 ) { return true ; } } } catch ( IOException | InterruptedException ex ) { LOGGER . debug ( "Path search failed for dotnet" , ex ) ; } return false ; }
Tests to see if a file is in the system path .