Question: java only: Write a method crawl accepts a File parameter and prints information about that file. If the File object represents a normal file, just

java only:

Write a method crawl accepts a File parameter and prints information about that file.

If the File object represents a normal file, just print its name.

If the File object represents a directory, print its name and information about every file/directory inside it, indented.

cse143

handouts

syllabus.doc

lecture_schedule.xls

homework

1-sortedintlist

ArrayIntList.java

SortedIntList.java

index.html

style.css

recursive data: A directory can contain other directories.

  • Your program should accept zero or more command-line arguments.
  • It should interpret each command-line argument as a (relative or absolute) pathname,
  • create a File object corresponding to this pathname, and
  • invoke the crawl method on this object,
  • which then prints the properly indented file/directory tree as shown on slide 34.

In addition,

  • if there is no file corresponding to the given pathname, your program should still print the pathname followed by "[not found!]"
  • if there is a file corresponding to the given pathname, your program should print the pathname followed by "[filesize"] where "filesize" is the size in bytes
  • if the pathname corresponds to a directory, your program should print a (forward) slash after the pathname

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!