Java Programming

Site Stats
APCS schedule | APCS LogIn | APCS Forms | APCS Resources | APCS Archive | APCS Stuff
Java schedule | Java LogIn | Java Forms | Java Resources | Java Archive | Java Stuff
Adven schedule | Adven LogIn | Adven Forms | Adven Resources | Adven Archive | Adven Stuff
Stats schedule | Stats LogIn | Stats Forms | Stats Resources | Stats Archive | Stats Stuff

Java substrings part 1 - directories and files

  Updated : January 11, 2010 10:16 AM

Output all the lines containing a file or a directory.

Input file : publicA.txt

Sample output

APCS Modification

Output the length of the line in parenthesis. Output the longest line, shortest line, and the average length of the lines. Below is part of the sample output.

10/15/2009 12:26 PM <DIR> .. (41)
08/24/2009 09:55 AM 44,498 00550AGL.jpg (51)
08/21/2009 09:46 AM 19,593 1950-59.docx (51)
08/21/2009 09:47 AM 14,231 1952.docx (48)
08/21/2009 09:55 AM 14,101 50's through 2002 overview.docx (70)
08/24/2009 09:52 AM 53,094 dna_toys.jpg (51)
08/24/2009 10:06 AM 33,226 fetal_8_weeks_fetus_circle_s1.jpg (72)
08/24/2009 09:50 AM 23,522 HeartExterior01.jpg770a3d1b-3197-45b3-8244-b94112b39522Large.jpg (103)
08/24/2009 10:02 AM 42,695 Odd-X-Rays.jpg (53)
08/24/2009 09:52 AM 40,102 poliopanic1.jpg (54)
10/15/2009 12:26 PM 58,673 pspbrwse.jbf (51)
Longest Line is 198 characters long
Shortest Line is 40 characters long
sum = 5450 count = 94
Average line length is 57.97872340425532

 

 

indexOf

public int indexOf ( String  str)

Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that: this.startsWith(str, k ) is true .

Parameters: str - any string.

Returns: if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.

 

 

 

  

H K N O P Sh Sm W
L Not Listed


Last Name :

Email :

Select one of the following that describes when and why you are filling out this form:
This assignment is in on time.
This assignment is in on time, being resubmitted due to a failed submission (I have a copy of the original submission).
This assignment is a corrected submission for half the missed credit.
This assignment is one day late and will lose 15%.
This assignment is more than one day late (half credit at best).
This assignment is late because of an EXCUSED absence.
This assignment is being resubmitted at the request of the teacher.


main method code

 

Updated: Monday, January 11, 2010 10:16 AM

 

 

 

About | Site Map | Contact | Search | ©2005 brentwoodhigh.com