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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:14:57+00:00 2026-06-02T12:14:57+00:00

I’m trying to read a file with buffered reader, but it skips first character

  • 0

I’m trying to read a file with buffered reader, but it skips first character in a line sometimes.
Here is the file, I’m reading:
http://files.moonmana.com/forums/Rectangle.h

here is the result, I’m getting:

LINE: #ifndef RECTANGLE_H
LINE: include "Shape.h"
LINE: lass Rectangle : public Shape {
LINE: rivate:
LINE: double _width;
LINE: std::vector<b2Vec2*>* _vertices;
LINE: ublic:
LINE: Rectangle(std::vector<b2Vec2*>* vertices) { _vertices = vertices;};
LINE: void createVertices();
LINE: bool isMimePoint(b2Vec2);
LINE: double getWidth(){return _width;};
LINE: void setWidth(double width);
LINE: void setHeights(double heights);
LINE: ShapeType getType();
LINE: void moveOn( b2Vec2 ,b2Vec2*);
LINE: virtual b2Vec2* getCenter();
LINE: ;
LINE: endif

Here is my source code:

String path = file.getPath();
BufferedReader _br;
    try {
        _br = new BufferedReader(new FileReader(path));

        do {
            System.out.println("LINE: " + _br.readLine());
            lines.add(_br.readLine());
        } while (_br.read() != -1);

        _br.close();
    } catch (Exception e) {
        System.out.println("Error reading file: " + e.getMessage());
    }
  • 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-02T12:14:59+00:00Added an answer on June 2, 2026 at 12:14 pm

    You are printing every second line and saving every second line and skipping the start of every second line. You read data in three places and use it different ways. Once you have _br.read() a character, it won’t read it again so it won’t appear in the line.

    A better approach is to use

    String line;
    while((line = _br.readLine()) != null) {
       System.out.println(line);
       lines.add(line);
    }
    

    As you can see it reads in one place and that values is used consistently.

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

Sidebar

Related Questions

I am trying to render a haml file in a javascript response like so:
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.