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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:36:11+00:00 2026-06-15T14:36:11+00:00

I have the following out put from a text file: =============================================== guideMenuSuite.mts: [monkeytalk:run] MonkeyTalk

  • 0

I have the following out put from a text file:

===============================================

guideMenuSuite.mts:
[monkeytalk:run] MonkeyTalk v1.0.11.beta5c_473 - 2012-07-18 11:38:51 MDT - Copyright 2012 Gorilla Logic, Inc. - www.gorillalogic.com
[monkeytalk:run] running suite guideMenuSuite.mts...
[monkeytalk:run] BCOKAS127271: -start suite (1 test)
[monkeytalk:run] BCOKAS127271:   1 : guide_menu.mt
[monkeytalk:run] BCOKAS127271:   -> OK
[monkeytalk:run] BCOKAS127271: -end suite
[monkeytalk:run] result: OK
[monkeytalk:run] ...done

================================================

In Java, I need to:
1) Parse the out put for the device serial number (BCOKAS127271 in this case…. it changes depending on what device is being tested).
2) Get the status results of the test which is after the -> (-> OK in this case).

I tried using split but the data keeps coming out null…

Any suggestions would be greatly appreciated.

here is my code:

CODE

while ((strLine = br.readLine()) != null) 
                {
                    maintextarea.append(strLine + "\n");
                    System.out.println(strLine);
                    System.out.flush();
                    maintextarea.append(selectedSerial);
                    delims = "[ \\->]+";
                    //String[] tokens = strLine.split(delims);
                    //String[] tokens = strLine.substring(prefix.length()).split(delims);

                    String noprefixStr = strLine.substring(strLine.indexOf(prefix) + prefix.length());
                    String[] tokens = noprefixStr.split(delims);

                    //for (String t: tokens)
                    {
                        //System.out.println(t);

                            if (tokens.toString().contains("ERROR"))
                            {
                                testStatus = "ERROR";
                                maintextarea.append("\n" + selectedValue + " " + selectedSerial + " = " + testStatus + "\n");
                                System.out.println(selectedValue + " " + selectedSerial + " = " + testStatus);
                                System.out.flush();
                            }

                            else if (tokens.toString().contains("FAILURE"))
                            {
                                testStatus = "FAILED";
                                maintextarea.append("\n" + selectedValue + " " + selectedSerial + " = " + testStatus + "\n");
                                System.out.println(selectedValue + " " + selectedSerial + " = " + testStatus);
                                System.out.flush();
                            }

                            else if (tokens.toString().contains("OK"))
                            {
                                testStatus = "PASSED";
                                maintextarea.append("\n" + selectedValue + " " + selectedSerial + " = " + testStatus + "\n");
                                System.out.println(selectedValue + " " + selectedSerial + " = " + testStatus);
                                System.out.flush();
                            }

                            else
                            {
                                testStatus = "N/A";
                                maintextarea.append("\n" + selectedValue + " " + selectedSerial + " = " + testStatus + "\n");
                                System.out.println(selectedValue + " " + selectedSerial + " = " + testStatus);
                                System.out.flush();
                            }

                    }


                }


                br.close();

============================================================

UPDATE:

I found my solution based on all the input that I received from this group!
I ended up making it really simple and parsing the out put file for an expression and then based on that setting a variable to pass or fail or error.

Here is the base code I used:

try 
        {
            BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(new FileInputStream("/home/ironmantis7x/Documents/TWC_test/MT_test_runner_output.txt"))));
            String strLine;
            while ((strLine = br.readLine()) != null)
            {
                if (strLine.contains("-> OK"))
                {
                    testStatus = "Pass";
                    System.out.println("Test Result = " + testStatus);
                }

            }
        } 

        catch (FileNotFoundException ex) 
        {
            Logger.getLogger(parseFile.class.getName()).log(Level.SEVERE, null, ex);
        }

Sorry it took me so long to get back to you guys and say thanks!

ironmantis7x

  • 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-15T14:36:11+00:00Added an answer on June 15, 2026 at 2:36 pm

    You can use regular expressions:

    import java.util.Pattern
    import java.util.Matcher
    
    Pattern status = Pattern.compile("\\[.*] \\w+:\\s+-> (\w+).*");
    
    ...
    

    You can learn how to do it here

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

Sidebar

Related Questions

I am trying to read in data from a text file and put it
So I have the following code to check for the text file called Doctors.txt
I have a text file with the following contents (delimiter is a single space):
I am running the following code to try and read from a text file.
I have a Java program that reads some text from a file, line by
Lets say I have a text file, and the text file contains the following:
I have some text which is loaded from a resource file. Ordinarily, to get
I have the following strings in a text file test Table Name.type Market Drinks.tea
Let's say I have the following text file: This is the first line of
I have the following code with reads a TXT file, pulls out unneeded info

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.