Supoose I have input a line "MOVE R1, R2", I split the words with respect to white space and store them individually into an array token[] as follows:
String[] token = new String[0];// array initialization
FileInputStream fstream = new FileInputStream("a.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
//Read file line by line and storing data in the form of tokens
While((strLine = br.readLine()) != null){
token = strLine.split(" ");// split w.r.t spaces
}
So the elements at each index are as follows: token[0]=MOVE token[1]=R1, token[2]=R2
But what I want is as follows: token[0]=MOVE token[1]=1 token[2]=2
I want to store only the numerical values in the token[i] where i>0, trimming off R and comma(,). I m unable to figure out how to use relaceAll() with arrays. How can I do that? Thanks in advance.