Well, I thought I found the answer at a Java site. It said if you use
the | it must be \\'ed then it will work. It looked like a solution
but when I tried it I got the same results.
strFields = strRecords[i].split("\\|");
With the |'s, strRecords[i] looks like:
R|2251|1|15,008.05|250|Maple Street|Smith, John|1848|......
After
strFields = strRecords[i].split("\\|");
strFields[0] looks like:
R|2251|1|15,008.05|250|Maple Street|Smith, John|1848|......
and it should just be R.
I am confused.
Thanks, John Brown
On Sep 28, 11:06 am, john brown <[email protected]> wrote:
> Hello,
>
> My understanding of String.split() and "\t" and "\n" seems to be
> incomplete. (I come from a DOS, Win, and VB enviornment.) I am in the
> habit of using Tab delimited 'records' in a text file where the
> records are delimited by CRLF. VB uses constants like vbTab and vbCrLf
> to refer to tabs and line feeds. And the Linux, Android enviornment
> utilizes \t and \n for the same things.
>
> The following code yields (I think) different responses depending on
> the source of strResponse. If strResponse originates in my Android
> Java code (as a paramater constructed in the code), the following code
> works just fine. But if strResponse is parsed from html document
> created by me using PHP on the server, then the two Log.d's produce
> exactly the same thing, the record which contains several "\t".
>
> // Start Code *****************
> String strRecords[] = strResponse.split("\n");
> String strFields[];
> Integer i;
> for (i = 0; i < strRecords.length; i++){
> strFields = strRecords[i].split("\t");
> Log.d("NQ109", TAG + " in addTaps strRecords[i] = " + strRecords[i]);
> Log.d("NQ109", TAG + " in addTaps strFields[0] = " + strFields[0]);}
>
> // End Code *****************
>
> I also tried to utilize "|", the pipe symbol, chr(124), but that just
> seems to split the record into an array of individual characters.
>
> What is the error in my understanding of the split() method?
>
> http://developer.android.com/reference/java/lang/String.html#split(ja...)
> does not seem to go deep enough for me to figure it out.
>
> Thanks, John Brown
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en