Split Strings
Hello Everyone,
I am just stuck with one problem. I would like to know how to separate strings and save the values to different ArrayList.
String("A1355469865 53")
I would like to add "A1355469865" to producList.add(A1355469865)
and sohList.add(53), It would be awesome if anyone could please help me out.
I have tried String.Split method but didnt really seem to work..
[407 byte] By [
sifatkhana] at [2007-11-27 4:58:18]

String[] splitLine = line.split("\\s+");
String[] parts = "A1355469865 53".split("\\s+"); producList.add(parts[0]); sohList.add(parts[1])
Thanks so much for the prompt replies guys, I will try the functions now. cheerz
Hi there
I am trying the following method :
try
{
TestFileReader reader = new TestFileReader(sFiles);
String str = reader.readLine();
while (!str.equals("#"))
{
String[] parts = str.split("\\s+"); ;
listBox1.set_Text(parts[0]);
str = reader.readLine();
}
}
but its coming up with an error:
Cannot Find method 'split(String)' in 'String'.
It would be greate if you could help
Thanks
What Java version are you using?
hi thereI am using visual j# 2005 express edition.Thanks
> hi there> I am using visual j# 2005 express edition.j# uses a really really old java version. It doesn't support regexp.Kaj
kajbja at 2007-7-12 10:14:08 >

(Never use j# if you want to do java development)
kajbja at 2007-7-12 10:14:08 >

What is the Java Version, not the IDE version?Edit: I see that was really slow.And I don't know much about J# (never used), but I am inclined to believe kaj, that it is using a really old version of Java, regardless of what additional Java versions that you have installed.
You are rightIt causes a lot of problems. However do you have any soltuion to my problem?thanks
> Sorry> Java 6What? So you aren't using visual j#?
kajbja at 2007-7-12 10:14:08 >

> You are right> > It causes a lot of problems. However do you have any> soltuion to my problem?> > thanksYes, download another IDE. There are good ones that are free. E.g. Netbeans, Eclipse, JBuilder (foundation)Kaj
kajbja at 2007-7-12 10:14:08 >

> You are right
>
> It causes a lot of problems. However do you have any
> soltuion to my problem?
>
> thanks
Yes. Don't use Visual J#. Download some other IDE (Netbeans, Eclipse, even JCreator or BlueJ before Visual J#), or don't use any IDE at all.
Edit: I can see I'm too slow again.
I am using j# as IDE and java 6 is installed on my computer. I also have Blue J and tried the above function giving me same errors:(..its not recognizing .spli().
> I am using j# as IDE and java 6 is installed on my> computer. J# isn't using Java 6 even if you have it installed on your machine. Configure your BlueJ to use Java 6 and you should be able to call split.Kaj
kajbja at 2007-7-21 21:16:36 >

I totally agree with you.But is there possibly any other reason of not recoginizing .split()?thanks
> I am using j# as IDE and java 6 is installed on my
> computer. I also have Blue J and tried the above
> function giving me same errors:(..its not recognizing
> .spli().
Did you attempt to configure the IDE to use the installed Java 6?
Installing Java 6 does not do this for you, you have to do it yourself.
Edit: Man still far too slow.
As far as an other explanation, the only other one would be that you are using a self-developed String class, or, somehow or another, have the rt.jar file from the old Java installation in your classpath before the rt.jar from the current version. (Not really sure if the second one is possible, but if it is you would have many more problems than just String.split)
> I totally agree with you.> > But is there possibly any other reason of not> recoginizing .split()?> > thanksYes, j# is using a very very old java version just as I said. That's the reason. It's not using Java 6.Kaj
kajbja at 2007-7-21 21:16:36 >

ThanksI am gonna try it on jBuilder :)..cheerz