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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:43:26+00:00 2026-05-17T14:43:26+00:00

alright so I am trying to read a text file. and then split it

  • 0

alright so I am trying to read a text file. and then split it up into lines which actually represent processes in a process table arraylist. then i want to split up all the tokens in the line and make all the tokens of the line an arraylist again so far this is all i have:

its not working correctly. i am getting:

processes:[[netscape, 1, 00ACF3, 20990, 12DFFE, 000F00, 000000, 000000, 000000, AF,   011356, 000000, 000000, 4FFFFF, 39AB00, 000000, 0A0B92, FFFFFF]]
processes:[[netscape, 1, 00ACF3, 20990, 12DFFE, 000F00, 000000, 000000, 000000, AF, 011356, 000000, 000000, 4FFFFF, 39AB00, 000000, 0A0B92, FFFFFF, textpad, 2, 391BCA, 871BAF, DEA14C, EEFC30, 000000, 000000, 0000AA, AF, 000000, 000000, 000000, 000000, 000000, FFFFFF, B4344D, 000000], [netscape, 1, 00ACF3, 20990, 12DFFE, 000F00, 000000, 000000, 000000, AF, 011356, 000000, 000000, 4FFFFF, 39AB00, 000000, 0A0B92, FFFFFF, textpad, 2, 391BCA, 871BAF, DEA14C, EEFC30, 000000, 000000, 0000AA, AF, 000000, 000000, 000000, 000000, 000000, FFFFFF, B4344D, 000000]]

BufferedReader inputStream = null;
ArrayList<ArrayList<String>> lines = new ArrayList<ArrayList<String>>();
ArrayList<String> tokens = new ArrayList<String>();
/* read the file*/
try {
    inputStream = new BufferedReader(new FileReader("p56.txt"));

    while (true) {
        /* while the file was read*/
        /* now. split the file into the lines.*/
        String line = inputStream.readLine();
        if (line == null) {
            break;
        }
        //if there are no more lines left. break

        // split the lines into tokens and make into an arraylist*/
        Scanner tokenize = new Scanner(line);
        while (tokenize.hasNext()) {
            /*while there are still more*/
            tokens.add(tokenize.next());
        }
        lines.add(tokens);

        System.out.println("processes:" + lines);
    }
}
  • 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-17T14:43:26+00:00Added an answer on May 17, 2026 at 2:43 pm

    You need to move the line

    ArrayList<String> tokens = new ArrayList<String>();
    

    to right before

    while (tokenize.hasNext()) {
    

    It will then create a new list of tokens before processing each line. Otherwise you will end up with a list of all tokens for all lines of the file.

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

Sidebar

Related Questions

Alright, what I'm trying to do is print out a few lines of text
Alright I have been trying to figure this out and I read the MSDN
Alright, so I'm trying to write a bunch of Sudoku puzzles to a file.
I'm trying to prepend a string a read-only, multi-line TextBox using the following code:
Alright so I'm trying to write a generic string deobfuscator (Similar to what .NET
Alright wasted hours and hours trying to get MSSQL Server 2008 to login via
Alright, I'm trying to see how many products are provided by each supplier (Products
Alright, I'm trying to link three different tables (Customers, Orders, and Order Details), in
Alright, be gentle, since I'm very much a novice to programming. So far I've

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.