Consider I have some big String in the following structure:
parameter1|parameter2|parameter3|parameter4+"\0"
*Where parameter is sequence of some chars in a generally unknown length.
Now consider my big String is holding 4 lines of data, for example:
parameter1|parameter2|parameter3|parameter4+"\0"
parameter1|parameter2|parameter3|parameter4+"\0"
parameter1|parameter2|parameter3|parameter4+"\0"
parameter1|parameter2|parameter3|parameter4+"\0"
How can I read the first line and then read the second line and so on?
I know that I can use Substring method to get the first line every time easily, however
how can I use Substring(or other methods) to get the next 3 lines of the big string, in order to extract the first line again (which represent the second line of the original big string in practice).
I know that all I need is the index of the last “\0” (line 4) and I already have the index of current line “\0”.
Should I just use lastIndexOf("\0")?
If you have any other ideas or even criticism about this way of working, I’ll be more than glad to hear about.
Thanks 🙂
You could use the String.split method with a
"\0"argument. You will then get an array of strings (String[]) which you can then do whatever you wish with 🙂