I believe that this can't be done the way that you are trying to do it, however there are ways to getting your data from the serial port. You could store the data on a variable or a file so you can later read that variable or file and get your data.
I am also using one array variable to store the serial data ..
My question is how much time Serial buffer can store that data...as I am getting data from 4 XBee modules every 5 seconds...
and the power on time for each XBee module is different....
So time gap between each XBee data may be 1 or 2 or or 3 or 4 seconds...
That is why I ma asking this question...
The Serial1 port on Galileo Gen 2 (ttyS0) can store the data for as long as you read it. The read function will get the data from the buffer and then clear the buffer. The buffer can store up to 64 characters (128 Bytes). You can create a loop that checks if data exists on the buffer; if data exists then call read function which will then clear the buffer's data. If you can read the data received every 5 seconds or faster (less than 5 seconds), the data being sent shouldn't get lost along the way.