I am working on an SMS application for Android where I am sending a number of Strings of predefined size in a single SMS. At the sending side, I am concatenating a number of Strings of predefined sizes. Once I have received the SMS, I want to split the long String into smaller Strings based on their sizes.
Here is a simple code to explain what I have attempted:
// On the SMS sending side
String str1 = new String(new char[8]);
String str2 = new String(new char[4]);
String str3 = new String(new char[2]);
String str4 = new String(new char[2]);
String sendSMS = str1 + str2 + str3 + str4;
// send SMS
After receiving the data I want to seperate the combined String into data for str1, str2, str3, str4, given that I know the size of each small Strings.
So far I have found a number of answers on SO, all of which use split() function, however I do not have a seperating character token between the concatenated Strings. Instead, I want to use the knowledge of the size of each substring to get them. Something similar to sscanf is what I am looking for.