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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:47:45+00:00 2026-05-23T17:47:45+00:00

I am trying to read product information from some text files. In my text

  • 0

I am trying to read product information from some text files. In my text file I have products and their information.

This is my file:

Product1:

ID: 1232
Name: ABC35

InStock: Yes

As you see, some products have blank lines in their product information, and I was wondering if there is any good way to determine if the line is blank, then read the next line.

How can I accomplish that? If the reading line is blank, then read the next line.

Thanks in advance for any help.

  • 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-23T17:47:46+00:00Added an answer on May 23, 2026 at 5:47 pm

    I think I may be misunderstanding. Assuming you have a BufferedReader, your main processing loop would be:

    br = /* ...get the `BufferedReader`... */;
    while ((line = br.readLine()) != null) {
        line = line.trim();
        if (line.length() == 0) {
            continue;
        }
    
        // Process the non-blank lines from the input here
    }
    

    Update: Re your comment:

    For example if I want to read the line after name, if that line is blank or empty, I want to read the line after that.

    The above is how I would structure my processing loop, but if you prefer, you can simply use a function that returns the next non-blank line:

    String readNonBlankLine(BufferedReader br) {
        String line;
    
        while ((line = br.readLine()) != null) {
            if (line.trim().length() == 0) {
                break;
            }
        }
        return line;
    }
    

    That returns null at EOF like readLine does, or returns the next line that doesn’t consist entirely of whitespace. Note that it doesn’t strip whitespace from the line (my processing loop above does, because usually when I’m doing this, I want the whitespace trimmed off lines even if they’re not blank).

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

Sidebar

Related Questions

I have a file that contains some information about the product I work on.
I am trying to read in an XML file that I have saved to
I am trying to read some XML code from a website, and am having
I am trying to read from a file and encrypt the data using AES
I am trying to read data from a HID device. I have a USB
I have following HTML which I am trying to read from the DOMNodeList when
Trying to read an RSS and select information using Linq but can't seem to
Trying to read headers for a csv file with: reader = csv.DictReader(open(PATH_FILE),skipinitialspace=True) headers =
Im trying to read a column of String values from my DB. Im trying
Iam trying to read a binary file to memory and pass the starting address

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.