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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:42:21+00:00 2026-05-11T16:42:21+00:00

Is there a way to read ahead one line to test if the next

  • 0

Is there a way to read ahead one line to test if the next line contains specific tag data?

I’m dealing with a format that has a start tag but no end tag.

I would like to read a line add it to a structure then test the line below to make sure it not a new “node” and if it isn’t keep adding if it is close off that struct and make a new one

the only solution i can think of is to have two stream readers going at the same time kinda suffling there way along lock step but that seems wastefull (if it will even work)

i need something like peek but peekline

  • 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-11T16:42:21+00:00Added an answer on May 11, 2026 at 4:42 pm

    The problem is the underlying stream may not even be seekable. If you take a look at the stream reader implementation it uses a buffer so it can implement TextReader.Peek() even if the stream is not seekable.

    You could write a simple adapter that reads the next line and buffers it internally, something like this:

     public class PeekableStreamReaderAdapter
        {
            private StreamReader Underlying;
            private Queue<string> BufferedLines;
    
            public PeekableStreamReaderAdapter(StreamReader underlying)
            {
                Underlying = underlying;
                BufferedLines = new Queue<string>();
            }
    
            public string PeekLine()
            {
                string line = Underlying.ReadLine();
                if (line == null)
                    return null;
                BufferedLines.Enqueue(line);
                return line;
            }
    
    
            public string ReadLine()
            {
                if (BufferedLines.Count > 0)
                    return BufferedLines.Dequeue();
                return Underlying.ReadLine();
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to read a file line by line in javascript, specifically
Is there a way to read raw data of a Sim card? Similar to
Is there any way to read/write the following data using php? And what is
Is there a way to have Linux read ahead when cloning a disk? I
Is there a way to read a locked file across a network given that
Is there a way to read a line from the Mongo shell? readline() is
Is there a way to read a text file into a one dimensional array
Is there any way to read a character from a specific location on the
Is there any way to read whole lines from a socket in Erlang, or
Is there a way to read a ByteBuffer with a BufferedReader without having to

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.