Package org.riversun.bigdoc.bin
Class BinFileSearcher
java.lang.Object
org.riversun.bigdoc.bin.BinFileSearcher
Search sequence of bytes from Binary file
- Author:
- Tom Misawa (riversun.org@gmail.com)
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault size to be read into memory at one searchstatic final intDefault number of threads used at the same time in one searchstatic final intDfault size of the window used to scan memory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()Returns the index within this file of the first occurrence of the specified substring.Returns the index within this file of the first occurrence of the specified substring, starting at the specified position.searchPartially(File f, byte[] searchBytes, long startPosition, long maxSizeToRead) Search for a sequence of bytes from the file within the specified size range starting at the specified position .searchPartiallyUsingNIO(File f, byte[] searchBytes, long startPosition, long maxSizeToRead, BinFileSearcher.BinFileProgressListener listener) voidSet the listener that callbacks the search-progressvoidsetBufferSize(int bufferSize) Set size to be read into memory at one searchvoidsetSubBufferSize(int subBufferSize) Set the size of the window used to scan memoryvoidsetSubThreadSize(int subThreadSize) Set number of threads used at the same time in one searchprotected voidvoidstop()Stop searching bytes
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEDefault size to be read into memory at one search- See Also:
-
DEFAULT_SUB_BUFFER_SIZE
public static final int DEFAULT_SUB_BUFFER_SIZEDefault number of threads used at the same time in one search- See Also:
-
DEFAULT_SUB_THREAD_SIZE
public static final int DEFAULT_SUB_THREAD_SIZEDfault size of the window used to scan memory- See Also:
-
-
Constructor Details
-
BinFileSearcher
public BinFileSearcher()
-
-
Method Details
-
cancel
public void cancel() -
setBufferSize
public void setBufferSize(int bufferSize) Set size to be read into memory at one search- Parameters:
bufferSize-
-
setSubThreadSize
public void setSubThreadSize(int subThreadSize) Set number of threads used at the same time in one search- Parameters:
subThreadSize-
-
setSubBufferSize
public void setSubBufferSize(int subBufferSize) Set the size of the window used to scan memory- Parameters:
subBufferSize-
-
setBigFileProgressListener
Set the listener that callbacks the search-progress- Parameters:
listener-
-
indexOf
Returns the index within this file of the first occurrence of the specified substring.- Parameters:
f-searchBytes-- Returns:
-
indexOf
Returns the index within this file of the first occurrence of the specified substring, starting at the specified position.- Parameters:
f- target filesearchBytes- a sequence of bytes you want to findfromPosition- "0" means the beginning of the file- Returns:
- position of the first occurence. '-1' means that it was not found.
-
search
- Parameters:
f-searchBytes-- Returns:
-
searchPartially
public List<Long> searchPartially(File f, byte[] searchBytes, long startPosition, long maxSizeToRead) Search for a sequence of bytes from the file within the specified size range starting at the specified position .- Parameters:
f-searchBytes- a sequence of bytes you want to findstartPosition- '0' means the beginning of the filemaxSizeToRead- max size to read.'-1' means read until the end.- Returns:
-
searchPartiallyUsingNIO
protected List<Long> searchPartiallyUsingNIO(File f, byte[] searchBytes, long startPosition, long maxSizeToRead, BinFileSearcher.BinFileProgressListener listener) -
sort
-
stop
public void stop()Stop searching bytes
-