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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:51:04+00:00 2026-05-30T14:51:04+00:00

I was experimenting with BufferedReader to read 1st line file to a string. How

  • 0

I was experimenting with BufferedReader to read 1st line file to a string. How do I do this? Also how can I read an entire file to a string? How to read a particular line like readline(int line) without iterating through the previous lines?

File namefile = new File(root, ".name");
FileReader namereader = new FileReader(namefile);
BufferedReader in = new BufferedReader(namereader);
  • 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-30T14:51:06+00:00Added an answer on May 30, 2026 at 2:51 pm

    You can use BufferedReader.readLine() to get the first line.

    Note that the next call to readLine() will get you the 2nd line, and the next the 3rd line….

    EDIT:

    If you want to specify a specific line, as your comment suggest – you might want to use Apache Commons FileUtils, and use: FileUtils.readLines(). It will get you a List<String> which you can handle like any list, including getting a specific line. Note that it has more overhead because it reads the entire file, and populates a List<String> with its lines.

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

Sidebar

Related Questions

Was experimenting with interface inheritance and found this: interface String{} interface Object{} interface Exception{}
While experimenting with this question on collections in Spring.NET , I discovered that Spring
I experimenting with WebView in Android and I can't figure out how to make
While experimenting a bit with C++ templates I managed to produce this simple code,
I'm experimenting with using couchdb as a message store and would like to report
Experimenting with Cocos2D collection detection and have some questions. First, some background: This is
In experimenting with this question I created an example that I utterly do not
I started experimenting with SVG and I'm not sure if this is something I'm
I'm doing some experimenting to try and get the file size smaller and I
I'm currently experimenting with generating sounds in Python, and I'm curious how I can

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.