android - Copy all files beginning with a certain letter -
what trying copy files 1 folder another. however, twist copy files 1 folder begin 123 , can follow.
for example have folder 3 files, 123__sdf.jpg, 123034.jpg , 321.jpg. want copy first 2 how select them only. because application dynamic files can change thats why want able select files begin 123.
first, want create file pointing directory. then, can use list
method list of files inside directory. can use startswith
check whether start 123 or not.
file dir = new file("/the/dir/"); if( dir.isdirectory() ){ string[] files = dir.list(); (string string : files) { if( string.startswith("123") ){ file file = new file(dir, string); // copy stuff } } }
list
method returns list of strings files , directories, may want use isfile()
method if want copy files.
Comments
Post a Comment