|
-
Feb 25th, 2001, 09:19 PM
#1
Thread Starter
Dazed Member
This should be an easy question for some of you java gurus to answer.
Im trying to add a binarySearch into some existing
code that i had but i keep getting a cannot resolve symbol error.
ie... method binarySearch (byte[],byte[])
I want to read a text file which is then stored into an
array. Then run a binarySearch on that array based on
the string value being passed into the class.. ie teststring
the signature for the binarySearch method i want to use
is public static int binarySearch(byte[] a, byte key);
what is a key???
import java.io.*;
import java.util.Arrays;
public static void test(String teststring){
try {
FileInputStream fin = new FileInputStream("C:\\test.txt");
byte[] buffer = new byte[64];
while(true){
int bytesread = fin.read(buffer);
if(bytesread == -1) break;
}
Arrays.sort(buffer); // first sort the array;
byte[] hold = teststring.getBytes();
Arrays.binarySearch(buffer,hold);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|