Fastest way to read and search a string in a large file using java
I want to read a file and search string in file and returns it's related value.
The file contains key and value pair and they are separated by space. Key is string and value is and URL in <a> tag, and the file size is 60MB.
I read the file using file Input stream and stored it into hash Map and performed searching into hash map, and it's taking less than a second to read the file and search a string and return it's value.
The searching in file having some rules as:
1. search string in file can be a sentence, we have to search the matching key into the file and return all the values(URL). and the search string length should be greater than 10.
2. if the search string contains _(underscore) at the end, then if the exact match(key) found in the file then no need to check the length of search string.
e.g. of Search Sting :
This is my first post to Java Programming Forums.
If the file contains Programming key, then we should have to return all URL related to this key.
I tried using file scanner, buffer Reader, File Input Stream and direct search in file and using hash map. But using hash map the performance was better.
Can please anybody suggest me how can I improve the performs so that I can achieve the file read and search within 5 Milliseconds. This will be an great help for me..
Thanks a lot in advance....
Re: Fastest way to read and search a string in a large file using java
Please re-read the forum FAQ, and abide by the forum rules including not double posting your question. Please choose which forum would be best for your question and close or delete the other one. I'll remove this comment once you've done that.