I wanted to know is there any specific method to filter file names and add specific files alone to a file array based on its prefix???
for example:
File: A_error_log.txt,A.txt,A.fasta,B.fasta,B_error_log.txt
From the above file list i just want to move the A type files to a folder and B type files to another folder.
A standard solution would be,get the list of files,then using get name check them for specific file name prefixes and add them.
I wanted to know is there any other method already present 4r this??
If you can tolerate an extra external dependency the filefilter package of Apache Commons IO has many premade filters for this kind of operations, what you want is easy to do with the WildcardFileFilter:
There are many other filters, and a set of “logic” filters (AndFileFilter, OrFileFilter and NotFileFilter) that allow you to string several filters together.
Should you decide to use Commons IO, in the FileUtils package there are a number of very interesting methods to move files around that also handle the case that a file has to be moved to another files system.