add if statement to check whether sampleFiles got any element

fix null exeption when there is no element in sampleFiles
@Benglin  may you check it