The title is probably not accurate but I hope that reading this post you can understand what I want to do.
I'm kind stuck in here. New in Java ME, that unfortunately has, as you know, reduced methods than the Java SE.
What I want to accomplish is this: I have a txt, with numbers in it separated by space. I want to put them in an array that can ""behave as an usual array in c++"" when one gets numbers separated by space into an array.
Now in J2ME what I've done (using Netbeans) is: I took the txt to a stream. Later sent the stream to a byte array and finally i converted it to a char array.
Let's say the original txt was: 98 2 12 13
Part of the code is:
InputStream is = getClass().getResourceAsStream("models.txt");
try{
int st_pk1_len = is.available();
byte st_pk1[] = new byte[st_pk1_len];
is.read(st_pk1);
char st_pk1_char[] = new String(st_pk1).toCharArray();
System.out.println(st_pk1_char);
What I get printed is: 98 2 12 13
Although, my problem is that when I want to access index 0 I get only the number 9 and not 98. If I try to reach the number 12, I put the pointer to 3 but what I get is an empty space and so on.
I've searched and tried different methods that I've found without luck to convert that into the original numbers again.
It could be a stupid mistake from my side or something that I've haven't think of.
Isn't there a simple solution to this problem?
update It's working now! Array is working as a "regular"c++ char array. In case somebody else need it or have my same problem, here is how it looks like:
InputStream is = getClass().getResourceAsStream("st_pk1.txt");
int st_pk1_len = is.available();
byte st_pk1[] = new byte[st_pk1_len];
is.read(st_pk1);
char st_pk1_char[] = new String(st_pk1).toCharArray();
String PreSplitted = new String(st_pk1);
String AftSplit[] = Split(PreSplitted, " ");
If you want to check: System.out.println(AftSplit[n]);
For the split method I used the second link in the Gnat's post. Split text in J2ME