mirror of https://github.com/01-edu/public.git
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
1.3 KiB
FileManager
Instructions
Create a file FileManager.java
.
Write a function createFile
that creates a file with the name and the content as parameter.
Write a function getContentFile
that returns the content of the file as parameter.
Write a function deleteFile
that deletes the file as parameter.
Expected Functions
public class FileManager {
public static void createFile(String fileName, String content) throws IOException {
// your code here
}
public static String getContentFile(String fileName) throws IOException {
// your code here
}
public static void deleteFile(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 {
FileManager.createFile("file.txt", "Lorem ipsum");
System.out.println(FileManager.getContentFile("file.txt"));
FileManager.deleteFile("file.txt");
}
}
and its output :
$ javac *.java -d build
$ java -cp build ExerciseRunner
Lorem ipsum
$