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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:01:29+00:00 2026-05-11T06:01:29+00:00

Hi I’m pretty new to Stack Overflow so I hope that I’m doing this

  • 0

Hi I’m pretty new to Stack Overflow so I hope that I’m doing this correctly and that someone out there has the answer I need.

I’m currently coding a program in Java with Eclipse IDE an my question is this:

I need a snippet of code that does the following

It’s supposed to get a .TXT file containing text and from that .TXT file count the number of rows and print it, count the number of words and print it, count the number of characters and print it. And finally make a list of the top 10 words used and print that.

Allt the printing is done to system outprintln

I’m pretty new to Java and am having some difficulties.

Anyone out there who can provide me with these lines of code or that knows where i can find them? I want to study the code provided that’s how I learn best=)

Thanks to all

Didnt find the edit button sorry…

I Added this to my question:

Hehe it´s an assignment but not a homework assignment ok i see well i could provide what i’ve done so far, i think im pretty close but it´s not working for me. Is there anything i have missed?

// Class    Tip   import java.io.*; import java.util.*;  class Tip {     public static void main(String [] args) throws Exception     {          String root = System.getProperty('user.dir');            InputStream is = new FileInputStream( root + '\\tip.txt' );         Scanner scan = new Scanner( is );          String tempString = '';         int lines = 0;         int words = 0;         Vector<Integer> wordLength = new Vector<Integer>();         int avarageWordLength = 0;          while(scan.hasNextLine() == true)         {                 tempString = scan.nextLine();                 lines++;         }          is.close();          is = new FileInputStream( root );         scan = new Scanner( is );          while(scan.hasNext() == true)         {                 tempString = scan.next();                 wordLength.add(tempString.length());                 words++;         }          for(Integer i : wordLength)         {                 avarageWordLength += i;         }         avarageWordLength /= wordLength.size();           System.out.println('Lines : ' + lines);         System.out.println('Words : ' + words);         System.out.println('Words Avarage Length : ' + avarageWordLength);          is.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. 2026-05-11T06:01:30+00:00Added an answer on May 11, 2026 at 6:01 am

    This sounds a bit too much like a homework assignment to warrant providing a full answer, but I’ll give you some tips on where to look in the Java API:

    FileReader and BufferedReader for getting the data in. Collections API for storing your data A custom data structure for storing your list of words and occurence count Comparator or Comparable for sorting your data structure to get the top 10 list out

    Once you’ve started work and have something functioning and need specific help, come back here with specific questions and then we’ll do our best to help you.

    Good luck!

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

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Fortunately there is a nice way to do it, just… May 11, 2026 at 8:56 pm
  • Editorial Team
    Editorial Team added an answer I would change it - i've got a legacy table… May 11, 2026 at 8:56 pm
  • Editorial Team
    Editorial Team added an answer Since this is code review, let's go one by one:… May 11, 2026 at 8:56 pm

Related Questions

Hi I am trying to deploy an application using webstart. I have a requirement
Hi i need to generate 9 digit unique account numbers. Here is my pseudocode:
Hi i want to write a game with a main game form and lot
Hi I'm trying to debug a stored procedure through SQL Analyzer and one of
Hi I'd like to schedule an existing job in the Sql Server 2005 agent

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.