package com.mergesort;

import jdk.internal.util.xml.impl.Input;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

/**
 * Please choose input data: 1 - from txt files, 2 - from keyboard.
 * If file does not exist - default input by keyboard.
 */

public class InputData {
//     public static void main(String[] args) {
//            chooseData();
//     }

    public static void chooseData() {
        System.out.println("\n Please choose input data: 1 - from txt files, 2 - from keyboard.\n If you choose: '1', and the file does not exist - default input by keyboard");
        Scanner in = new Scanner(System.in);
        System.out.println("\n Choose: 1 - from txt files, 2 - from keyboard");
        int methodDataEntry = in.nextInt();
        if (methodDataEntry == 1) {
            //System.out.println("\nYour choose: 1 - from txt files");
            filesData();
        } else {
            //System.out.println("\nYour choose: 2 - from keyboard");
            keyboardData();
        }
    }

    public static void filesData() {

        ClassLoader classLoader = InputData.class.getClassLoader();
        File file = new File(classLoader.getResource("inputdata.txt").getFile());

        try (FileReader reader = new FileReader(file)) {
            int c;
            while ((c = reader.read()) != -1) {
                System.out.print((char) c);
                //inputStream = new BufferedReader(new FileReader("xanadu.txt"));
                //http://www.mkyong.com/java/how-to-read-file-from-java-bufferedinputstream-example/
            }
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }
        //int[] array = new int[];
        //return array;
    }

    public static int[] keyboardData() {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter the length of the array:");
        int arrayLength = in.nextInt();
        System.out.println("Input " + arrayLength + " numbers");
        int[] array = new int[arrayLength];
        for (int i = 0; i < arrayLength; i++) {
            int inputDataNumber = in.nextInt();
            array[i] = inputDataNumber;
        }
        return array;
    }
}
@@ -74,20 +74,17 @@
 java.io.
-File
+*
 ;%0Aimport
@@ -93,40 +93,26 @@
 ava.
-io.FileReader;%0Aimport java.io.IO
+util.InputMismatch
 Exce
@@ -528,83 +528,61 @@
 .%5Cn 
-If you choose: '1', and the file does not exist - default input by keyboard
+Default input by keyboard, if the file does not exist
 %22);%0A
@@ -646,26 +646,24 @@
 em.out.print
-ln
 (%22%5Cn Choose:
@@ -667,45 +667,8 @@
 se: 
-1 - from txt files, 2 - from keyboard
 %22);%0A
@@ -763,178 +763,37 @@
     
-//System.out.println(%22%5CnYour choose: 1 - from txt files%22);%0A            filesData();%0A        %7D else %7B%0A            //System.out.println(%22%5CnYour choose: 2 - from keyboard%22);
+filesData();%0A        %7D else %7B
 %0A   
@@ -871,17 +871,16 @@
 ata() %7B%0A
-%0A
         
@@ -1095,17 +1095,22 @@
     int 
-c
+foobar
 ;%0A      
@@ -1123,17 +1123,22 @@
 while ((
-c
+foobar
  = reade
@@ -1200,194 +1200,16 @@
 ar) 
-c);%0A                //inputStream = new BufferedReader(new FileReader(%22xanadu.txt%22));%0A                //http://www.mkyong.com/java/how-to-read-file-from-java-bufferedinputstream-example/
+foobar);
 %0A   
@@ -1317,67 +1317,8 @@
   %7D%0A
-        //int%5B%5D array = new int%5B%5D;%0A        //return array;%0A
     

create Resources root for inputdata.txt files