string problem...!!!!
hmm...how 2 separate the contain in the document file that ended with dot into lines.
lets say, in this document we have...
halo how r u. I'm fine. tq.
after using some coding become like this...
halo how r u.
I'm fine.
tq.
i hope u all can help me to solve this problem..thx
If I were you I would just read the whole line into a String (s, for example), then any time I wanted one of those pieces I would say
String piece = s.substring(0, s.instanceOf( '.' ) );
s=s.substring( s.instanceOf('.')+1,s.length);
Note that if the period is at the end of the String or if there's no period in the String this will crash, so it requires a little more work, but I have two minutes to get to class. Note that the above code is untested.
is this what you are looking for
String src = "a,b,c,d,e,f,g";
String s[] = src.split(",");
for (int i = s.length - 1; i >=0; i --) {
System.out.println(s[i]);
}
> is this what you are looking for
>
> > String src = "a,b,c,d,e,f,g";
> String s[] = src.split(",");
>
> for (int i = s.length - 1; i >=0; i --) {
>System.out.println(s[i]);
> }
>
>
but i just wan split the line that ended with dot " . "
if i use a.split( " . " )
it cannot work...
> but i just wan split the line that ended with dot "
> . "
You've been given a couple of approaches.
> if i use a.split( " . " )
> it cannot work...
That's because you didn't read the docs closely enough. Split takes a regex.
inputString.split("\\.")
jverda at 2007-7-16 20:27:40 >
