algorithm - Java : How to find string patterns in a LARGE binary file? -


I am trying to write a program that will read a very large binary file and try to find the event of 2 different stars And then print those indexes that match the pattern. For example, suppose that the alphabet sequence is [h, e, l, l, o] and [h, e, l, l, o, w, o, r, L, D] .

I was able to code it for small binary files because I was reading each character as a byte and then saving it to Arraylist . Then starting with the beginning of Aheri list , I was comparing the byte array list (byte [] data) with byte [] pattern .

I need to find a way to do this, but without compiling the entire binary file in memory for comparison, it means that I should be able to compare each character during reading (memory Should not save the entire binary file in) Let's assume that the binary file contains only letters.

Any suggestions on how this can be achieved? Thanking you guys in advance.

Google "finite state machine"

Or, read the file one byte at a time, if the byte does not match the first letter of the search term, then go to the next byte, if it matches, then now you can see the next character in the sequence Are looking for. That is, your state has become 0 to 1. If your state is equal to the length of the search string (or pass), then you found it!

Execution / Debugging Excluded from Reader


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -