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

  • Home
  • SEARCH
  • 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 6652407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:08:06+00:00 2026-05-26T01:08:06+00:00

Possible Duplicate: How do I split strings in J2ME? I have a String data

  • 0

Possible Duplicate:
How do I split strings in J2ME?

I have a String data which is like csv , that is there are “;” inside the String data. But in my case there is always a “;” at the end of the String. I want to create a method which gives a String at a certain number from this csv. For example :

String csv = "145557;123456789012;Michael Robert;1000000;200000;;12/05/2011;;" ;

In this String there are 8 “columns“. I say “column” the data between two “;” ( the first column is not enclosed by two “;” but only the one at its right ).

In this example the data “Michael Robert” has the number 2 ( or 3 if we start at 1 for the first column ).

So how to get the data ( column ) at a specified number ?

NB : I use Java ME

  • 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-05-26T01:08:06+00:00Added an answer on May 26, 2026 at 1:08 am

    In J2ME you can write a method like this:

    public class Main {
    
        public static void main(String[] args) {
            String csv = "145557;123456789012;Michael Robert;1000000;200000;;12/05/2011;;" ;
            System.out.println(getColumnAt(csv, 0));
            System.out.println(getColumnAt(csv, 1));
            System.out.println(getColumnAt(csv, 2));
        }
    
        public static String getColumnAt(String csv, int column) {
            int fromIndex = 0;
            int col = 0;
            while (col < column) {
                fromIndex = csv.indexOf(";", fromIndex) + 1;
                col++;
            }
            int toIndex = csv.indexOf(";", fromIndex);
            return csv.substring(fromIndex, toIndex);
        }
    }
    

    UPDATE: By the way, due to the way that substring is implemented it is better to return new String(csv.substring(fromIndex, toIndex));, otherwise the substring will hold a reference to the original string and then as long as the substring is not GC-able, the original String won’t be GC-able as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: splitting a string i have a string which looks like this: http://pastebin.com/m5508ff19
Possible Duplicate: Split string, convert ToList<int>() in one line… i have a string that
Possible Duplicate: Regular expression, split string by capital letter but ignore TLA I have
Possible Duplicate: Split String into smaller Strings by length variable I have seen solutions
Possible Duplicate: Is There A Built-In Way to Split Strings In C++? i have
Possible Duplicate: Split string in SQL I have seen a couple of questions related
Possible Duplicate: How to split string into array as integers I have a 3x2
Possible Duplicate: How can I split an IEnumerable<String> into groups of IEnumerable<string> I have
Possible Duplicate: string split in java I have this Key - Value , and
Possible Duplicate: PHP preg_split string into letter pairs I have an string looking like

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.