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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:18:39+00:00 2026-05-30T02:18:39+00:00

I am doing a custom validation for text files. For the first time, validation

  • 0

I am doing a custom validation for text files. For the first time, validation is done for whole file. The errors if any, are shown in another JTextArea. After that validation is done to only those part which is visible. My problem is i am not able to store the previous errors and combine with the current errors to show. For example, First time, i get errors in
line 1, line 5, line 6, line 100, line 500. from next time the visible part will be 1-50 lines, the validation will be done only for 1-50, so the error of 100 and 500 going off. I tried it by storing the previous errors in a temp variable, the next problem is, Now the privious errors will become only for 1-50, Can someone tell me how to go about it?.

The code i tried,

      private void displayError() {
      errorText.setText(null); 
      String err = null;
      try{
        //tempErrors
        if(!prevErrors.isEmpty()){
            for(int i=0; i< prevErrors.size(); i++){
                err = prevErrors.get(i).toString();
                if(!errors.contains(err)){
                    errors.add(prevErrors.get(i).toString());
                }
            }
        }
    }
    catch(Exception ex){
        System.out.println(ex);
    }        

    Iterator it = errors.iterator();
    while(it.hasNext()){
        errorText.append(it.next() + "\n");
    }

    prevErrors = new ArrayList();        
    for(int i=0; i< errors.size(); i++){
       prevErrors.add(errors.get(i).toString());
    }
}
  • 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-30T02:18:41+00:00Added an answer on May 30, 2026 at 2:18 am

    Your problem can be solved simpler using a TreeMap:

    1. Create an TreeMap<Integer, String> and call it errors. (The key is line number and the value is the error information.)
    2. Parse the file once and fill the errors-map with the found errors (and lines)

    When a part of the file is visible you use the subMap method to get the errors within that part:

    SortedMap<Integer, String> visibleErrors = errors.subMap(fromLine, toLine + 1); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm unclear about when and how I should be doing validation in my custom
I have a custom DataAnnotationsModelValidatorProvider for doing model validation in a more dynamic way
I would like to know, how can I call another custom validation method of
As it says in the title, I'm doing custom validation with FCK (because the
I'm doing custom drawing in datagridview cells and I have items that can vertically
I'm doing a custom 404 page for a large website that's undergoing a redesign.
I am doing a custom control (inherited from VisualBasic.PowerPacks.LineShape ), that should be painted
I'm overriding the drawRect: method in a custom UIView, and I'm doing some custom
Lately I've been doing a lot of custom styling in SharePoint by modifying the
I'm writing a custom TCP server and client and on doing a ton of

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.