java - How can move file from one directory to another -


i sorry,i modified entire question.

i want move specific files(based on fileextension) 1 directory another.

for this, plan write 2 functions names listoffilenames , movingfiles.

if pass directorypath , filetype arguments tolistoffilenames(),it returns list<file>data.this list have entire file path.

movingfiles() move files source directory destination.

i tried movingfiles function, in following way.it's not working.

public void movingfiles(string sourcepath,string directorypath,string filetype) throws ioexception {     externalfileexecutions externalfileexecutionsobject=new externalfileexecutions();     list<file> filenames=externalfileexecutionsobject.listoffilenames(sourcepath, filetype);     (int fileindex = 0; fileindex < filenames.size(); fileindex++)      {         filenames[fileindex].renameto(new file(directorypath+"/" + filenames[fileindex].getname()))     } } 

i think, need convert list<file> list<string>.that's why asked that.

@tbodt replyed question.i failed integrate answer in function.so modified question.

again sorry, modifying entire question.

thanks.

if want list<string> each element canonical path of corresponding file, how:

list<string> list = new arraylist<string>(); (file file : finallistnames)     list.add(file.getcanonicalpath()); 

if that's not want, please clarify.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -