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

  • Home
  • SEARCH
  • 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 8422331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:24:59+00:00 2026-06-10T03:24:59+00:00

Possible Duplicate: Storing file content into an array I’m programming a simple hangman program.

  • 0

Possible Duplicate:
Storing file content into an array

I’m programming a simple hangman program. I am having difficulty with opening a file, and then storing the data into an array. I can’t seem to figure out how to do it. This is for a school project so if the logic seems unnecessary, just blame the man 🙂

I have a text file (words.txt) with ten words in it. They are in the file with a line in between each of them. They need to be imported into an array. Anyone care to help a young aspiring programmer out? Thanks for any help you can give!

  • 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-10T03:25:00+00:00Added an answer on June 10, 2026 at 3:25 am

    I suggest you use a List<String> (such as ArrayList<String>) and a Scanner (construct it using new Scanner(new File("wordfile.txt")), and use scanner.hasNextLine()/scanner.nextLine()) to read the words.

    If you indeed need it to be an array, go through list.toArray in the end.

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

Sidebar

Related Questions

Possible Duplicate: Inserting PHP array into Javascript array I'm reading a file in server
Possible Duplicate: HTML5 local storage sort I am storing data into a localstorage using
Possible Duplicate: What is the best way to slurp a file into a std::string
Possible Duplicate: Python: How to read huge text file into memory To process a
Possible Duplicate: C/C++, can you #include a file into a string literal? I have
Possible Duplicate: Storing a file in the user’s directory in cross-platform Java I am
Possible Duplicate: Easiest way to get file's contents in C My program reads files
Possible Duplicate: What is the best way to slurp a file into a string
Possible Duplicate: Get file name from URI string in C# How to extract file
Possible Duplicate: Enforcing spaces in string resources This is the strings.xml file I use

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.