// Determines if a file of numbers contains any duplicate elements (anywhere)

import java.io.*;
import java.util.*;

public class DupChecker {
	public static void main(String [] args) throws Exception {
		Scanner keyboard = new Scanner(System.in);

		System.out.print("filename? ");
		String filename = keyboard.next();

		Scanner scanner = new Scanner(new File(filename));

		final int CAPACITY = 100;
		int [] arr = new int[CAPACITY];
		int size = 0;

		while (scanner.hasNextInt()) {
			int num = scanner.nextInt();
			if (contains(arr, size, num)) {
				System.out.println("There is at least one pair of duplicates in the file");
				System.exit(0);
			}
			if (size >= CAPACITY) {
				System.out.println("Insufficient array capacity -- make your arrays larger");
				System.exit(1);
			}
			arr[size] = num;
			size++;
		}

		System.out.println("No duplicates found");
	}

	static boolean contains(int [] arr, int size, int val) {
		for (int i = 0; i < size; i++)
			if (arr[i] == val) return true;
		return false;
	}
}
