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

The Archive Base Latest Questions

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

I am writing a compiler program to read a text file. Some of the

  • 0

I am writing a compiler program to read a text file. Some of the commands in the text file will tell me to skip back to a certain line in the text file and read from there. As things are, this code I have reads one line at a time until the end of the document. Is there anyway to have a parser skip back or forward to a certain line in the text file? Let us say for example I am currently on line 8 and the instruction is to go back and read line 4?

Here is my code for parsing the file.

try {
    FileInputStream fstream = new FileInputStream("compilers.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
    String strLine;

    while ((strLine = br.readLine()) != null && checker == false) {
        // rest of code in here
    }
    in.close();
}
  • 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-15T21:11:21+00:00Added an answer on June 15, 2026 at 9:11 pm

    You could do this with a Map

    HashMap<Integer, String>
    

    Key is your line number and value is your line. So you can get the line by line number when you required.

    Map<Integer, String> lineMap = new HashMap<Integer, String>();
    int i = 1;
    while ((strLine = br.readLine()) != null && !checker) {
        lineMap.put(i, strLine);
        // do what you want
        // if you are in line 8 (i=8)
        // get my line 4 (lineMap.get(4))
        i++;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program that will guess words taken from a big text file.
I am writing a program to read lines of text from 5 files and
In my application I compile another program from source.cs file using CodeDom.Compiler and I
I am writing a c++ program to read/write a large file (probably larger than
I am writing a program that will read in a list of names with
I am trying to read from a file and write the output to a
I'm writing a program that is creating a lookup table from two tables that
I am writing a program that reads a file, whose first two lines are:
I'm writing a program that sits in the systray. It will have a keyboard
I'm writing a command line program in ANSI C to parse a Quake 2

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.