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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:23:32+00:00 2026-05-21T18:23:32+00:00

I guess this will sound crazy, but I am reading from a file, and

  • 0

I guess this will sound crazy, but I am reading from a file, and it seems like it skips the first line of the file.

What is going on?

Here is the source:


    private void loadFile(String fileNPath)
    {
        StringBuilder currentFileContents = new StringBuilder();
        CharBuffer contentsBuffer = CharBuffer.allocate(65536);

        int status=0;
        try
        {
            BufferedReader in = new BufferedReader(new FileReader(fileNPath));

            while(status!=-1)
            {
                status=in.read(contentsBuffer);
                currentFileContents.append(contentsBuffer);
                contentsBuffer.clear();
            }

            System.out.println(currentFileContents.toString());
        }
        catch(FileNotFoundException n)
        {
            //Should be imposible
        }
        catch(IOException n)
        {
            n.printStackTrace(System.out);
        }

    }

It must be something I am over looking.

I copied and pasted the exact source, so I hope this happens for you also.

Thanks,
caalip

  • 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-21T18:23:33+00:00Added an answer on May 21, 2026 at 6:23 pm

    I would use FileUtils.readFileToString(file) which does this in one line.

    However, when I run your code on a text file I see every line. I suspect the problem is not with your code.

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

Sidebar

Related Questions

I guess this question will sound familiar, but I am yet another programmer baffled
This may sound like a weird question but I will give it a shot
My guess is that this question will fall under the category of duh, but,
I guess there will be a very simple answer to this. But here goes.
I guess no one will have a definative answer to this but considered predictions
It appears this code will request the file in Chrome and IE but not
I guess this will be a silly mistake but for me, the following returns
I guess this will be already answered somewhere, so apologies in advance, but I
I know this is going to sound silly but I can't find what's wrong.
I guess my main question is, will this always work as long as I

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.