Here is my code.....I dont know quite what's wrong with it....i cant seem to get it to read the numbers into the array. Any help/tips would be great!. Thanks!
import java.io.*;
public class fileprocessing {
public static void main(String[] args) throws IOException {
int size=10;
int number;
int target=0;
int[] array = new int[size];
File inputFile = new File("numbers.rtf");
FileReader text = new FileReader(inputFile);
File outputFile = new File("cis326.rtf");
FileWriter out = new FileWriter(outputFile);
for (int i=0; i<size; i++)
{
text.read();
number = array[i];
}
System.out.println(array[5]);
search(array, target);
}
static public int search(int [] array, int target)
{
int high = array.length, low = -1, probe;
while (high - low > 1)
{
probe = (high + low) / 2;
if (array[probe] < target)
low = probe;
else
high = probe;
}
if (high == array.length || array[high] != target)
return -1;
else
return high;
}
}