Here is a method that outputs a range of numbers to a file:
public static void printRangeToFile(String file, boolean append, int fromIncl, int toExcl) {
try (FileWriter writer = new FileWriter(file, append)) {
for (int i = fromIncl; i < toExcl; i++) {
writer.write(i + " ");
}
} catch (IOException e) {
System.out.printf("An exception occurred %s", e.getMessage());
}
}
We invoke it three times as below:
String filepath = "file.txt"; // relative path to the file
printRangeToFile(filepath, false, 0, 10);
printRangeToFile(filepath, true, 10, 20);
printRangeToFile(filepath, false, 20, 30);
Which of the following describes the data in this file?
Note: spaces used as separators are not considered as data.