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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:23:20+00:00 2026-05-13T13:23:20+00:00

I wrote a simple java application, I have a problem please help me; I

  • 0

I wrote a simple java application, I have a problem please help me;

I have a file (JUST EXAMPLE):

1.TXT
-------
SET MRED:NAME=MRED:0,MREDID=60;
SET BCT:NAME=BCT:0,NEPE=DCS,T2=5,DK0=KOR;
CREATE LCD:NAME=LCD:0;
-------

and this is my source code

import java.io.IOException;
import java.io.*;
import java.util.StringTokenizer;

class test1 {

    private final int FLUSH_LIMIT = 1024 * 1024;
    private StringBuilder outputBuffer = new StringBuilder(
            FLUSH_LIMIT + 1024);
    public static void main(String[] args) throws IOException {
        test1 p=new test1();
        String fileName = "i:\\1\\1.txt";
        File file = new File(fileName);
        BufferedReader br = new BufferedReader(new FileReader(file));
        String line;
        while ((line = br.readLine()) != null) {
            StringTokenizer st = new StringTokenizer(line, ";|,");
            while (st.hasMoreTokens()) {
                String token = st.nextToken();
                p.processToken(token);

            }
        }
        p.flushOutputBuffer();
    }

    private void processToken(String token) {
        if (token.startsWith("MREDID=")) {
            String value = getTokenValue(token,"=");
            outputBuffer.append("MREDID:").append(value).append("\n");
        } else if (token.startsWith("DK0=")) {
            String value = getTokenValue(token,"=");
            outputBuffer.append("DK0=:").append(value).append("\n");
        } else if (token.startsWith("NEPE=")) {
            String value = getTokenValue(token,"=");
            outputBuffer.append("NEPE:").append(value).append("\n");
        }
        if (outputBuffer.length() > FLUSH_LIMIT) {
            flushOutputBuffer();
        }
    }

    private String getTokenValue(String token,String find) {
        int start = token.indexOf(find) + 1;
        int end = token.length();
        String value = token.substring(start, end);
        return value;
    }

    private void flushOutputBuffer() {
        System.out.print(outputBuffer);
        outputBuffer = new StringBuilder(FLUSH_LIMIT + 1024);
    }

}

I want this output :

MREDID:60
DK0=:KOR
NEPE:DCS

But this application show me this :

MREDID:60
NEPE:DCS
DK0=:KOR

please tell me how can i handle this , because of that DK0 must be at first and this is just a sample ; my real application has 14000 lines

Thanks …

  • 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-13T13:23:20+00:00Added an answer on May 13, 2026 at 1:23 pm

    Instead of outputting the value when you read it, put it in a hashmap. Once you’ve read your entire file, output in the order you want by getting the values from the hashmap.

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

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I was able to figure out the answer and was… May 13, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer Calling .parents(".box .something1") will return all parent elements that match… May 13, 2026 at 10:14 pm
  • Editorial Team
    Editorial Team added an answer The code is defining an anonymous function (the (function (){… May 13, 2026 at 10:14 pm

Related Questions

I am trying to do a simple application using Ajax and servlet. But when
I am new to web programming, coming from a video game development background (c++),
I am learning OpenGL and just started getting into lighting. I enable lighting and
I've got an application here that I wrote many years ago that consists of
At what point is it better to switch from java.net to java.nio? .net (not

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.