String.split() missing in leJOS?

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

String.split() missing in leJOS?

Postby werner291 » Sun Jan 01, 2012 2:58 pm

Hello, I recently had some strange behavior from the nxj compiler. After de-compiling the classes.jar, I found out why.

In the official JDK, the String class provides the "String[] split(String)" and the "String[] split(String, int)" methods.
These seem to be missing from "String.class" in classes.jar.

Does the nxj compiler use the JDK or classes.jar?
werner291
New User
 
Posts: 5
Joined: Sat Dec 10, 2011 12:22 pm

Re: String.split() missing in leJOS?

Postby gloomyandy » Sun Jan 01, 2012 3:23 pm

Hi,
For code running on the NXT leJOS uses its own set of class files located in classes.jar. There is no need to decompile the file we supply all of he source files as part of the standard install, or you can browse them on line... So for instance the String class is here...
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
You can also see the API docs for the NXT here:
http://lejos.sourceforge.net/nxt/nxj/api/index.html
I suspect that reason split is missing is the use of regular expressions. I don't think we have an implementation of those (which can be relatively large) for the NXT...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3892
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: String.split() missing in leJOS?

Postby skoehler » Sun Jan 01, 2012 3:50 pm

gloomyandy wrote:I suspect that reason split is missing is the use of regular expressions. I don't think we have an implementation of those (which can be relatively large) for the NXT...


Exactly. The argument of String.split() is a regular expression. And we don't have an implementation of java.util.regexp for the NXT.
skoehler
leJOS Team Member
 
Posts: 1390
Joined: Thu Oct 30, 2008 4:54 pm

Re: String.split() missing in leJOS?

Postby werner291 » Sun Jan 01, 2012 3:55 pm

Ok, I'll see if I can find some other workaround in that case.
werner291
New User
 
Posts: 5
Joined: Sat Dec 10, 2011 12:22 pm

Re: String.split() missing in leJOS?

Postby djschembri » Sat Mar 03, 2012 4:46 pm

Don't know if you've solved it but you can use substring instead of split
djschembri
New User
 
Posts: 6
Joined: Mon Nov 28, 2011 10:41 pm

Re: String.split() missing in leJOS?

Postby werner291 » Sun Mar 04, 2012 5:24 pm

Yes, I have solved it. I just wrote a small function that cut up the string at every space character.
werner291
New User
 
Posts: 5
Joined: Sat Dec 10, 2011 12:22 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff