Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Required Methods Within your package a5, create a file named FileUtils.java. Import File at the top of this file: import java.io.File;. Within your FileUtils

image text in transcribed

The Required Methods Within your package a5, create a file named FileUtils.java. Import File at the top of this file: import java.io.File;. Within your FileUtils class, write two methods matching the following signatures. You should not use other Java libraries to solve the problem for you. 1. /** * Returns a file (not directory) of the given name located at or within * fileOrDirectory, according to the file's getName() method. * If fileOrDirectory has the given name, it itself is returned. * Returns null if no matching file is found. * If multiple files match the given name, any of them may be returned. * * * @param name the string name of the file to find (not including the file path) @param fileOrDirectory the file or directory to start searching from * @return a File f located at or within fileOrDirectory that has the provided input name, or null if no such file is found. * public static File findFile(String name, File fileOrDirectory) { This method makes use of the getName() File method (documentation here), which returns the string name of a file. For example, the value of getName() for the file you are writing these methods in should be "FileUtils.java". Assuming your directory structure matches the structure in the screenshot above, some example behavior follows: findFile("FileUtils.java", new File("src")); // should return a File pointing to the file you're editing findFile("RandomFileName.java", new File("src")); // should return null

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

2. What should an employer do when facing an OSHA inspection?

Answered: 1 week ago