There is no built in method that does this.
Use the overloaded String#indexOf(String, int) method that accepts a starting position. Keep looping until you get -1, always providing the result of the previous call as the starting position. You can add each result in a List and convert that to an int[] later.
Alternatively, use Pattern and Matcher, looping while Matcher#find() returns a result.
Here are a few examples:
public static void main(String[] args) {
String command = "-u User -P Password mkdir \"temp dir\" rmdir \"host dir\"";
List<Integer> positions = new LinkedList<>();
int position = command.indexOf("\"", 0);
while (position != -1) {
positions.add(position);
position = command.indexOf("\"", position + 1);
}
System.out.println(positions);
Pattern pattern = Pattern.compile("\"");
Matcher matcher = pattern.matcher(command);
positions = new LinkedList<>();
while (matcher.find()) {
positions.add(matcher.start());
}
System.out.println(positions);
}
prints
[26, 35, 43, 52]
[26, 35, 43, 52]