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 8811041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:15:55+00:00 2026-06-14T03:15:55+00:00

I’d like to get a string from my ArrayList, but it contains lines from

  • 0

I’d like to get a string from my ArrayList, but it contains lines from my input fole. How do I split them correctly to have all the elements?

My program looks like this:

private static ArrayList<String> lista;

static void fileReading() {
    inp = new LineNumberReader(new BufferedReader(new InputStreamReader(new FileInputStream(inFileNev), "ISO8859-1")));

    String sor;
    while ((sor = inp.readLine()) != null) {

    lista.add(sor);
    lista.add(System.getProperty("line.separator"));   
}

In another method how do I get this lists only one string and not the line?

EDIT:

Vineet Verma your code is great, but it gets me a great string, and I need to know the indexes of the strings within this, replace them later, and I can’t get it done with only one string.

It’s still not working, if I use this:

    String[] temp=null;
for(String s : lista) {
   temp = s.split("\\W+"); 
} 

System.out.println(temp);

I get: [Ljava.lang.String;@6ef53890

Wihtin the for I get many : [Ljava.lang.String;@6ef53890

If I use this:

   String str ="" ;
    for(int i=0; i<lista.size(); i++){
     str+=lista.get(i)+" ";

  String[] temp = new String[str.length()];
  for(int i=0; i < str.length(); i++) {
       temp[i]=str.valueOf(i);
       System.out.println(temp[i]);         
  }

I get only numbers, and can’t figure out how to get the string from str.

  • 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-14T03:15:56+00:00Added an answer on June 14, 2026 at 3:15 am

    Use this code for your problem:

    in the other method

    public String convertToString(ArrayList<String> al)
    {
    String str ="" ;
    for(int i=0; i<al.size;i++){str+=al.get(i)+" ";}
    return str;
    }
    

    If i understand your query correctly then this is the solution

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I would like to count the length of a string with PHP. The string
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have two tables with like below codes: Table: Accounts id | username |

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.