write a java program
With a given data file called data.txt contains integer numbers, write a program that will open the file and read all the integer numbers and determine how many numbers were read, the smallest number, the largest number, the sum of all numbers, and the average value. The result should be stored into a file called dataOutput.txt. The program should also sort all numbers in ascending order and output the results (10 numbers per line) into a file mentioned. Your program should implement Java ArrayList class, Java File I/O, and Java error handling excaption.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
class Main{
public static void main(String[] args) {
//Scanner to read the data
Scanner obj = null;
try {
obj = new Scanner(new File("data.txt"));
} catch (FileNotFoundException e) {
System.out.println("File not found");
return;
}
//Initiaize min and max
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
int sum = 0;
int count = 0;
//List to store numbers
List<Integer> list = new ArrayList();
//Read all ints
while(obj.hasNextInt()){
count++;
int x =obj.nextInt();
//Update min and max. Find sum
min = Math.min(x,min);
max = Math.max(x,max);
sum += x;
//Add to list
list.add(x);
}
//Find avg
double avg = sum/count;
//Print results
System.out.println("Minimum : "+min);
System.out.println("Maximum : "+max);
System.out.println("Average : "+avg);
//Sort the data
Collections.sort(list);
int ind = 0;
//Print the list
for(int x : list){
System.out.print(x+" ");
ind++;
//For every 10th element, print new line
if(ind%10==0){
System.out.println();
}
}
}
}
OUTPUT :

write a java program With a given data file called data.txt contains integer numbers, write a...