java - Copy jpg from folder to folder on Linux -
i'm using files.copy(sourcefile,destfile) apache's commonsio lib, in order copy jpg 1 folder on linux machine.
actually i'm doing pic's in folder :
file folder = new file(sourcepath); file[] foldercontent = folder.listfiles(); file tmp = null; file sourcefile = null; file destfile = null; //copy pics other folder : for(int i=0;i<foldercontent.length;i++){ if(foldercontent[i].getname().endswith("jpg")){ sourcefile = new file(sourcepath); destfile = new file(destpath); //copy main dir: files.copy(sourcefile,destfile); } }
but in new folder empty files (with correct name). when tested simple test 1 file ,like : files.copy(sourcefile,destfile); file copy successfully.
does have clue ?? (is java-linux known issue ?)
thanks!
this no linux issue.
first, use source folder source file, not file itself.
also, possibly, use use destination folder copy target.
assuming destpath destination folder:
for(file file : foldercontent){ if(file.getname().endswith("jpg")){ files.copy(file, new file(destpath, file.getname())); } }
Comments
Post a Comment