You can use the function split
:
String[] words = yourString.split(" ");
int currency = Integer.parseInt(words[0]);
String currencyFrom = words[1];
String currencyTo = words[2];
1
solved How can I split a string by a delimiter in Java? [duplicate]