Your task is to write a program in java that uses a textfile
Your task is to write a program in java that uses a textfile containing any number of lines of integer values as input. Each line in the file is supposed to have no more than 15 values in it. If the file exists and each line in the file does in fact contain 15 or fewer integers, then the program processes and reports on each line in turn by displaying its line number, the number of values on that line, and the range of values on the line.
Note: You must implement exception handling. Not only am I requiring it, but Java itself will also require it since you will have to use Java resources that force you to deal with the IOException. In addition to this exception, you are also required to handle the ArrayIndexOutOfBounds and the NumberFormatException at appropriate points in your program.
 Your program should read in, from the command line, the name of a text file containing any number of lines of integers and then process each line in turn. Processing a line means computing and then reporting, for that line, its line
 number, along with the range of values on the line.
 The program should recognize a number of problems that may occur when trying to process such a file. First, the file itself may not be present. If so, the
 following message is displayed:
 filename.txt (the system cannot find the file specified).
 Program will now terminate.
 If the file exists, and contains lines of integers, possibly with blank lines,
 possibly lines with too many values, and possibly lines with invalid integers
 on them, then the following messages are output, as appropriate:
 Line #: Number of values = # and value range = [#, #].
 Line #: This is a blank line.
 Line #: This line contains more than the maximum of 15 allowed data values.
 Line #: This line contains an invalid integer value.
For example, if a file named “text.txt” contains the following text:
 1 2 30
 3 4 5
 2 3 4 5 6.5 7
 abs sej jdh& 4
 1 2 3 4 5 6 6 6 8 99 0 0 -1
 34 34 23
 24
 1 2 3 4 5 6 7 8 9 10 -2 3 4 5 6 7
 1
 Then the output should be like this:
 Output:
 The file test.txt was successfully opened.
 The data in it will now be processed.
 Press Enter to continue ...
 Line 1:Number of values = 3 and value range is [1, 30].
 Line 2:This is a blank line.
 Line 3:Number of values = 3 and value range is [3, 5].
 Line 4:This line contains an invalid integer value.
 Line 5:This line contains an invalid integer value.
 Line 6:Number of values = 13 and value range is [-1, 99].
 Line 7:Number of values = 3 and value range is [23, 34].
 Line 8:Number of values = 1 and value range value range consists of this single value.
 Line 9:This line contains more than the maximum of 15 allowed data values.
 Line 10:Number of values = 1 and value range value range consists of this single value.
Solution
import java.io.File;
 import java.io.IOException;
 import java.util.Scanner;
public class FileProcessing {
   public static void main(String[] args) {
        Scanner scanner = null;
        try {
            File file = new File(\"text.txt\");
           if (!file.exists()) {
                System.out.println(\"file not found\");
                throw new IOException();
            } else {
                System.out
                        .println(\"The file test.txt was successfully opened.\");
                System.out.println(\"The data in it will now be processed.\");
                System.out.print(\"Press Enter to continue ...\");
                scanner = new Scanner(System.in);
                scanner.nextLine();
               scanner = new Scanner(file);
                int lineNum = 0;
                while (scanner.hasNext()) {
                   System.out.print(\"Line \" + ++lineNum + \":\");
                    String line = scanner.nextLine();
                    // System.out.println(line);
                    if (line.isEmpty()) {
                        System.out.println(\"This is a blank line.\");
                        continue;
                   }
                    int arr[] = new int[15];
                    int count = 0;
                    try {
                       String[] lineArr = line.split(\" \");
                        if (lineArr.length > 15) {
                            throw new ArrayIndexOutOfBoundsException();
                       }
                        for (int i = 0; i < lineArr.length; i++) {
                            arr[count++] = Integer.parseInt(lineArr[i]);
                       }
                        if (count == 1) {
                            System.out
                                    .println(\"Number of values = \"
                                            + count
                                            + \" and value range value range consists of this single value\");
                       } else
                            System.out.println(\"Number of values = \" + count
                                    + \" and value range is [\"
                                    + getMin(arr, count) + \", \"
                                    + getMax(arr, count) + \"].\");
                   } catch (ArrayIndexOutOfBoundsException e) {
                        // TODO: handle exception
                        System.out
                                .println(\"This line contains more than the maximum of 15 allowed data values.\");
                    } catch (NumberFormatException e) {
                        // TODO: handle exception
                        System.out
                                .println(\"This line contains an invalid integer value.\");
                    }
}
           }
        } catch (IOException e) {
            // TODO: handle exception
            System.out.println(\"\");
        }
    }
   public static int getMax(int[] arr, int count) {
        int max = arr[0];
        for (int i = 0; i < count; i++) {
            if (max < arr[i])
                max = arr[i];
        }
        return max;
}
   public static int getMin(int[] arr, int count) {
        int min = arr[0];
        for (int i = 0; i < count; i++) {
            if (min > arr[i])
                min = arr[i];
        }
        return min;
   }
 }
text.txt
1 2 30
3 4 5
 2 3 4 5 6.5 7
 abs sej jdh& 4
 1 2 3 4 5 6 6 6 8 99 0 0 -1
 34 34 23
 24
 1 2 3 4 5 6 7 8 9 10 -2 3 4 5 6 7
 1
OUTPUT:
The file test.txt was successfully opened.
 The data in it will now be processed.
 Press Enter to continue ...
 Line 1:Number of values = 3 and value range is [1, 30].
 Line 2:This is a blank line.
 Line 3:Number of values = 3 and value range is [3, 5].
 Line 4:This line contains an invalid integer value.
 Line 5:This line contains an invalid integer value.
 Line 6:Number of values = 13 and value range is [-1, 99].
 Line 7:Number of values = 3 and value range is [23, 34].
 Line 8:Number of values = 1 and value range value range consists of this single value
 Line 9:This line contains more than the maximum of 15 allowed data values.
 Line 10:Number of values = 1 and value range value range consists of this single value



