I'm working on a data struct project and can't seem to find out why I am getting this exception. When I run my project in eclipse this is the error it gives.
Exception in thread "main" java.io.EOFException
at java.io.RandomAccessFile.readInt(RandomAccessFile.java:803)
at java.io.RandomAccessFile.readLong(RandomAccessFile.java:836)
at project_test.BTree.<init>(myClassB.java:75)
at project_test.URLTestBNode.main(myClassA.java:25)
Does it simply mean that it cannot locate the URL I gave it?
Looking at relevant code around lines 25:
public class myClassA {
20) public static void main(String[] args) throws FileNotFoundException, IOException, URISyntaxException {
21) URL url1 = new URL("The first URL");
22) URL url2 = new URL("The second URL");
23) RandomAccessFile rf1 = new RandomAccessFile(url1.toString().replace("/",""),"rw");
24) RandomAccessFile rf2 = new RandomAccessFile(url2.toString().replace("/",""),"rw");
25) BTree tree1 = new BTree(rf1, 64); //Error this line
26) BTree tree2 = new BTree(rf2, 64);
...
}
}
Relevent code around line 75:
public class myClassB{
69) public myClassB(RandomAccessFile f, int k) throws IOException, FileNotFoundException{
71) file = f;
72) file.seek(0);
73) byte[] url = new byte[256];
74) file.read(url);
75) long rootIndex = file.readLong(); //This line
76) file.seek(rootIndex);
...
}
}
The only thing I can really think of is if it can't find the stored URL for some reason or if it's not registering that I added the exception in there. Any ideas on what I can do to troubleshoot this problem?