private static bool IsQuoted(bool noQuotesInside, String arg, String errorMessage) { int lastPos = arg.Length() - 1; if (lastPos >= 1 && arg.CharAt(0) == '"' && arg.CharAt(lastPos) == '"') { // The argument has already been quoted. if (noQuotesInside) { if (arg.IndexOf('"', 1) != lastPos) { // There is ["] inside. throw new IllegalArgumentException(errorMessage); } } return(true); } if (noQuotesInside) { if (arg.IndexOf('"') >= 0) { // There is ["] inside. throw new IllegalArgumentException(errorMessage); } } return(false); }