Reputation: 133
Is there a best/shortest way of doing this:
java -cp . compare %rel1% %rel2% > out
set /p result=<out
del out
Upvotes: 3
Views: 400
Reputation: 56208
your code is the shortest, but it needs a temporary file, which makes it slow.
The "usual" method to get the output of a command is a for
loop:
for /f %%a in ('java -cp . compare %rel1% %rel2%') do set result=%%a
(to use it on command line, use a single percent sign only %a
instead of %%a
)
There are a lot of options with the for
command, which makes it one of the most useful commands in batch. See for /?
for details.
Upvotes: 3