You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1.3 KiB

FileSearch

Instructions

Create a file FileSearch.java.

Write a function searchFile that returns the path of the file in parameter. You need to start searching from a folder named documents at the root of the current folder.
The file to search can contain a subfolder and the file can be in any of them.

Expected Functions

public class FileSearch {
    public static String searchFile(String fileName) {
        // your code here
    }
}

Usage

Here is a possible ExerciseRunner.java to test your function
import java.io.IOException;

public class ExerciseRunner {
    public static void main(String[] args) throws IOException {
        System.out.println(FileSearch.searchFile("file.txt"));
    }
}

Create the following arborescence :

\ documents
| --- file.csv
| --- \ rep
      | --- example.txt
      | --- file2.csv
      | --- file2.xml
      | --- \ directory33
            | --- file.txt
            | --- test.png
      | --- \ directory22
            | --- test.gif
| --- \ directory435
      | ---test33.xls
          

and its output :

$ javac *.java -d build
$ java -cp build ExerciseRunner 
document/rep/directory33/file.txt
$ 

Notions

File