Monthly Archives: July 2014

Logical operators AND, OR in batch

There is no method to combine operators in windows BATCH command shell.
But we can easily emulate it!

For AND operator use next snippet:

if %var% GEQ 1 (
    if %var% LEQ 10 (
        // do...
    )
)

For OR operator we have to use additional variable:

set result=false

if %var% LEQ 0 set result=true
if %var% GEQ 10 set result=true

if "%result%" EQU "true" (
   // do...
)

Thanx to http://stackoverflow.com/a/2143396

Capitalize word algorithm in Java

capit
Here is simple snippet to capitalize string:

private static String capitalize(String value) {
    return value == null ? null : 
        value.substring(0, 1).toUpperCase() + value.substring(1);
}

Simple!

Thanx to
http://stackoverflow.com/questions/5725892/how-to-capitalize-the-first-letter-of-word-in-a-string-using-java