Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » problems with String.split(String)
problems with String.split(String) [message #120249] Mon, 24 November 2003 11:34 Go to next message
Eclipse UserFriend
Originally posted by: pavel.math.utexas.edu

Hello,
I am having problems using the method java.util.String.split(String) which
is supposed to split up
a string into an array of strings while cutting out a delimiter. For some
reason, when I use it, it
gives me an error. Could someone advise me as to how I should approach
this problem? I am
using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
Thank you.

Sincerely,
Paul Gribeluyk
Re: problems with String.split(String) [message #120286 is a reply to message #120249] Mon, 24 November 2003 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsk.email.arizona.edu

Paul, we need some more details. What isn't working? What is the error?
Do you get an exception? What is it?

Split does work how you mentioned, so take the sentence:
"I like dogs" and do this:
String[] array = "I like dogs".split(" ");

this will return me:
array[0] = "I";
array[1] = "like";
array[2] = "dogs";

Is this how you are using it? Split TAKES a regular expression, so its
handy that most of the time simple characters will work, but if you pass
in soemthing like "?" which is a reserved character for regular
expressions, then you need to escape it "\\?" if you actually wanted to
split on question marks.

Best,
-Riyad

Paul Gribelyuk wrote:

> Hello,
> I am having problems using the method java.util.String.split(String) which
> is supposed to split up
> a string into an array of strings while cutting out a delimiter. For some
> reason, when I use it, it
> gives me an error. Could someone advise me as to how I should approach
> this problem? I am
> using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
> Thank you.
>
> Sincerely,
> Paul Gribeluyk
>
Re: problems with String.split(String) [message #120653 is a reply to message #120286] Mon, 24 November 2003 23:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pavel.math.utexas.edu

So here is how I use split:

BufferedReader buffread1 = new BufferedReader (new FileReader ( in1));
String exp = buffread1.readLine();
String [] expvalues = exp.split(",");

The file in1 contains double values, two per line, separated by commas.
The error message that I
get is this:

"the method split(String) is undefined for the type String"

Thank you for the help.

Cheers,
Paul Gribelyuk

Riyad Kalla wrote:

> Paul, we need some more details. What isn't working? What is the error?
> Do you get an exception? What is it?

> Split does work how you mentioned, so take the sentence:
> "I like dogs" and do this:
> String[] array = "I like dogs".split(" ");

> this will return me:
> array[0] = "I";
> array[1] = "like";
> array[2] = "dogs";

> Is this how you are using it? Split TAKES a regular expression, so its
> handy that most of the time simple characters will work, but if you pass
> in soemthing like "?" which is a reserved character for regular
> expressions, then you need to escape it "\?" if you actually wanted to
> split on question marks.

> Best,
> -Riyad

> Paul Gribelyuk wrote:

> > Hello,
> > I am having problems using the method java.util.String.split(String) which
> > is supposed to split up
> > a string into an array of strings while cutting out a delimiter. For some
> > reason, when I use it, it
> > gives me an error. Could someone advise me as to how I should approach
> > this problem? I am
> > using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
> > Thank you.
> >
> > Sincerely,
> > Paul Gribeluyk
> >
Re: problems with String.split(String) [message #120664 is a reply to message #120653] Mon, 24 November 2003 23:51 Go to previous messageGo to next message
Eclipse UserFriend
It would appear that you are compiling against 1.3 libraries.
String.split(String) was added in 1.4

HTH
Darins

"Paul Gribelyuk" <pavel@math.utexas.edu> wrote in message
news:bpulqn$8e0$1@eclipse.org...
> So here is how I use split:
>
> BufferedReader buffread1 = new BufferedReader (new FileReader ( in1));
> String exp = buffread1.readLine();
> String [] expvalues = exp.split(",");
>
> The file in1 contains double values, two per line, separated by commas.
> The error message that I
> get is this:
>
> "the method split(String) is undefined for the type String"
>
> Thank you for the help.
>
> Cheers,
> Paul Gribelyuk
>
> Riyad Kalla wrote:
>
> > Paul, we need some more details. What isn't working? What is the error?
> > Do you get an exception? What is it?
>
> > Split does work how you mentioned, so take the sentence:
> > "I like dogs" and do this:
> > String[] array = "I like dogs".split(" ");
>
> > this will return me:
> > array[0] = "I";
> > array[1] = "like";
> > array[2] = "dogs";
>
> > Is this how you are using it? Split TAKES a regular expression, so its
> > handy that most of the time simple characters will work, but if you pass
> > in soemthing like "?" which is a reserved character for regular
> > expressions, then you need to escape it "\?" if you actually wanted to
> > split on question marks.
>
> > Best,
> > -Riyad
>
> > Paul Gribelyuk wrote:
>
> > > Hello,
> > > I am having problems using the method java.util.String.split(String)
which
> > > is supposed to split up
> > > a string into an array of strings while cutting out a delimiter. For
some
> > > reason, when I use it, it
> > > gives me an error. Could someone advise me as to how I should
approach
> > > this problem? I am
> > > using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
> > > Thank you.
> > >
> > > Sincerely,
> > > Paul Gribeluyk
> > >
>
Re: problems with String.split(String) [message #120675 is a reply to message #120664] Mon, 24 November 2003 23:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsk.email.arizona.edu

ditto

Darin Swanson wrote:
> It would appear that you are compiling against 1.3 libraries.
> String.split(String) was added in 1.4
>
> HTH
> Darins
>
> "Paul Gribelyuk" <pavel@math.utexas.edu> wrote in message
> news:bpulqn$8e0$1@eclipse.org...
>
>>So here is how I use split:
>>
>>BufferedReader buffread1 = new BufferedReader (new FileReader ( in1));
>>String exp = buffread1.readLine();
>>String [] expvalues = exp.split(",");
>>
>>The file in1 contains double values, two per line, separated by commas.
>>The error message that I
>>get is this:
>>
>>"the method split(String) is undefined for the type String"
>>
>>Thank you for the help.
>>
>>Cheers,
>>Paul Gribelyuk
>>
>>Riyad Kalla wrote:
>>
>>
>>>Paul, we need some more details. What isn't working? What is the error?
>>>Do you get an exception? What is it?
>>
>>>Split does work how you mentioned, so take the sentence:
>>>"I like dogs" and do this:
>>>String[] array = "I like dogs".split(" ");
>>
>>>this will return me:
>>>array[0] = "I";
>>>array[1] = "like";
>>>array[2] = "dogs";
>>
>>>Is this how you are using it? Split TAKES a regular expression, so its
>>>handy that most of the time simple characters will work, but if you pass
>>>in soemthing like "?" which is a reserved character for regular
>>>expressions, then you need to escape it "\?" if you actually wanted to
>>>split on question marks.
>>
>>>Best,
>>>-Riyad
>>
>>>Paul Gribelyuk wrote:
>>
>>>>Hello,
>>>>I am having problems using the method java.util.String.split(String)
>
> which
>
>>>>is supposed to split up
>>>>a string into an array of strings while cutting out a delimiter. For
>
> some
>
>>>>reason, when I use it, it
>>>>gives me an error. Could someone advise me as to how I should
>
> approach
>
>>>>this problem? I am
>>>>using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
>>>>Thank you.
>>>>
>>>>Sincerely,
>>>>Paul Gribeluyk
>>>>
>>
>
>
Re: problems with String.split(String) [message #121901 is a reply to message #120664] Tue, 25 November 2003 15:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pavel.math.utexas.edu

So I guess my next question would be how to fix it. I've downloaded the
1.4 libraries, but I'm not
sure how to let eclipse know that. Any ideas?


Cheers,
Paul Gribelyuk

Darin Swanson wrote:

> It would appear that you are compiling against 1.3 libraries.
> String.split(String) was added in 1.4

> HTH
> Darins

> "Paul Gribelyuk" <pavel@math.utexas.edu> wrote in message
> news:bpulqn$8e0$1@eclipse.org...
> > So here is how I use split:
> >
> > BufferedReader buffread1 = new BufferedReader (new FileReader ( in1));
> > String exp = buffread1.readLine();
> > String [] expvalues = exp.split(",");
> >
> > The file in1 contains double values, two per line, separated by commas.
> > The error message that I
> > get is this:
> >
> > "the method split(String) is undefined for the type String"
> >
> > Thank you for the help.
> >
> > Cheers,
> > Paul Gribelyuk
> >
> > Riyad Kalla wrote:
> >
> > > Paul, we need some more details. What isn't working? What is the error?
> > > Do you get an exception? What is it?
> >
> > > Split does work how you mentioned, so take the sentence:
> > > "I like dogs" and do this:
> > > String[] array = "I like dogs".split(" ");
> >
> > > this will return me:
> > > array[0] = "I";
> > > array[1] = "like";
> > > array[2] = "dogs";
> >
> > > Is this how you are using it? Split TAKES a regular expression, so its
> > > handy that most of the time simple characters will work, but if you pass
> > > in soemthing like "?" which is a reserved character for regular
> > > expressions, then you need to escape it "?" if you actually wanted to
> > > split on question marks.
> >
> > > Best,
> > > -Riyad
> >
> > > Paul Gribelyuk wrote:
> >
> > > > Hello,
> > > > I am having problems using the method java.util.String.split(String)
> which
> > > > is supposed to split up
> > > > a string into an array of strings while cutting out a delimiter. For
> some
> > > > reason, when I use it, it
> > > > gives me an error. Could someone advise me as to how I should
> approach
> > > > this problem? I am
> > > > using the 2.12 build of Eclipse and the OS is Apple's Mac OS X 10.2.8.
> > > > Thank you.
> > > >
> > > > Sincerely,
> > > > Paul Gribeluyk
> > > >
> >
Re: problems with String.split(String) [message #123964 is a reply to message #121901] Tue, 02 December 2003 17:19 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

You need to configure Eclipse to use this as your JRE. Look under
Preferences > Java > Installed JREs. Add the 1.4 JRE and set it as the
default JRE.
--

Paul Gribelyuk wrote:
> So I guess my next question would be how to fix it. I've downloaded the
> 1.4 libraries, but I'm not
> sure how to let eclipse know that. Any ideas?
>
Previous Topic:Source Locator does not exist
Next Topic:How to link View to Editor?
Goto Forum:
  


Current Time: Thu May 01 23:46:38 EDT 2025

Powered by FUDForum. Page generated in 0.04975 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top