-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
31 lines (28 loc) · 916 Bytes
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sort.*;
import java.util.Arrays;
import java.util.*;
import java.io.*;
public class Main{
public static void main(String args[]) {
System.out.println("Hello World");
int[] arr = getIntegerFromFile("intQuickSort.txt");
//MergeSort sorter = new MergeSort(arr);
QuickSort sorter = new QuickSort(arr);
sorter.sort();
//System.out.println(Arrays.toString(sorter.getSortedArray()));
}
private static int[] getIntegerFromFile(String filename){
Scanner sc = null;
int n = 10000; int i = 0;
int[] arr = new int[n];
try{
sc = new Scanner(new File(filename));
} catch (FileNotFoundException e) {
System.err.println("FileNotFoundException: " + e.getMessage());
}
while (sc != null && sc.hasNextInt()){
arr[i++] = sc.nextInt();
}
return arr;
}
}