I am writing a program for binary search on contents of a file.
The steps involved in it are:
1. Have to read a file[Inputing the filename from the user] - using bufferedReader.readLine() method[bufferedReader = new BufferedReader(new InputStreamReader(new FileInputSteam(filename)))]
2. Have to search the number[entered by user] in the contents of file [using Binary Search]
3. Have read from the file and input the contents in a int array.
The problem arises here:
The array i formed and then sorted[2 different methods] have some zero values[as I am not able to determine actually how many numbers are there in the file, so took an arbitrary int array of size 20, but the file contains only 6 numbers, hence there are 14 "0" values].
However besides the values, the method works flawlessly
Any solutions how to determine how many numbers are present in the file[cannot use fileInputStream.read() == -1 as stated above].
Thanks in advance