Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:43:00+00:00 2026-06-02T06:43:00+00:00

The title is probably not accurate but I hope that reading this post you

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:43:01+00:00Added an answer on June 2, 2026 at 6:43 am

    You can treat the char array as String, containing tokens separated by space: new String(st_pk1) does that for you.

    After that, you need to split it, like as described in couple other Stack Overflow questions:

    • How do I split strings in J2ME?
    • Split text in J2ME
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think the title for this question is probably wrong, but I'm not sure
This sounds like a weird title and probably not stated too well. But here's
As you can probably tell by the title, I'm not sure the best way
Okay that's probably not the best title, I know why we need browser resets:
Alright, probably not the best title, but meh. I have the following code inside
Probably not the best title I've ever written, but I find it hard to
Probably not the best title, but I'll explain: I have an array of objects
I am not sure that the title is saying it right, most probably it
There is probably a very simple answer to this, but I want to be
Ok, so that title probably doesn't explain my question well. Hopefully this makes sense.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.