• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding calculating the sum of map key and map alue overall  RSS feed

 
naresh saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the application in which user select the particular folder and all the files in that folder along with the line of code in those individual files is counted and at the console along with the file names and the line of code in to them is displayed ..here is my piece of code ...

but I want to add one more functionality that while at the console it is displaying individual file name along with the line of code into them , at last it should also display total files read let say it reads 6 files from a particular folder so it should display total files read is 6 and total lines of all the files lets assume those 6 individual files have 10 piece of line of code each have then sum of lines is 10*6 that is 60 total lines read, how to achieve this please advise

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) To get a count of the files, you have two options - either keep an integer that you increment for each file you read, or look at the Map's size()

2) To get the total count of lines you read you should keep a totalCount variable that starts at 0 and you add the lineCount for each file you read in.
 
naresh saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:1) To get a count of the files, you have two options - either keep an integer that you increment for each file you read, or look at the Map's size()

2) To get the total count of lines you read you should keep a totalCount variable that starts at 0 and you add the lineCount for each file you read in.


First thing I have achieved that is the total number of files read below is shown the piece of code..




please advise for To get the total count of lines that is total lines of all the files lets assume those 6 individual files have 10 piece of line of code each have then sum of lines is 10*6 that is 60 total lines read, how to achieve this please advise
 
naresh saxena
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks ,

Achieved that thing also..

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!