I'm doing a basic search based program using file handling where there's a thousand random words (every word is on a separate line) in a file and a user can run the program, put a word in, and if it happens to be in the file, it will tell the user that the word was found and if the word isn't in the file then it will inform the user that it isn't in the file...
A teacher of mine suggested that it would be a great way to learn a bit about threading using java as well and use four threads that scan different parts of the file (so thread one will check from word 1 - 250, thread 2 checks from 251 to 500 and so on and so forth)...
I have understood how to do it and can visualize how it will work but then I'm struggling with this one issue, how do I make the cursor/character pointer to line number say 250 so that the second thread can immediately start from line 250, same for thread 3 where I want to make it jump to line number 500... I don't exactly know how to do it... I scanned through the Oracle help center for like 20-30 minutes to find anyway, and the best I could find is a function called "skip(int bytes)" which takes the number of bytes to skip as an argument but I don't know how many bytes there are in between line number 0 to 250 since they're random words and the words could change from folder to folder! is there a way I could use that would help me skip to a specific line in the file and continue from there in java?