I have 100 files named "1.exe","2.exe","3.exe",...,"100.exe" I want to take input from user as 1,2,3,... or 100 and run the corresponding exe file. For example if user inputs 45 , I will run file "45.exe" I don't want to use ifs or switches. Can anyone please help me.
If the input is always equal to the filename of your exes you can do it with:
if( isInputNumberBetween1And100() )
Runtime.getRuntime().exec( input + ".exe" );
Runtime.getRuntime().exec( input + ".exe" ).waitFor();
will work if you want to to wait for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With