1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Java

Connected

Exercise

Finding local files

You want to write a small program which will print only the local files in a given directory. You have been able to retrieve the list of elements in the directory, stored in DIRECTORY_CONTENT, but :

  • All elements contain first the type, then the element
  • /d means directory,
  • /f means file
  • Some files are hidden, and contain a "."
  • Files in other directors should not be printed Let's fix those now!

Instructions

100 XP
  • Use .substring(a,b) and .contains("") to check if the element if file or directory.
  • Check whether a file is hidden when it containsa ".".
  • Check that a file is local by making sure it doesn't contain a "/".
  • Use the correct logical operator to use both conditions at the same time.