Online for the file operation many function tool class, no can self-surfing internet search download use, here I only provide a file moving (cut) method
/**
* Move the source files under the established folder
*/
public static void Movesrc2tag () {
//destination file
File Tagfile = new file (Localzippath);
source file
if (!tagfile.exists ())
Tagfile.mkdirs ();
File fold = new ("lijing");//files to be moved
File Fnew = new file (Localzippath + "//" + fold.getname ());
Fold.renameto (fnew);
}
There are a lot of ways to cut the first copy to the specified path, and then delete the files that need to be moved, but this is a bit verbose, this method is relatively simple.
Here are some of the ways I can use multiple files in my project.
/**
* Move the annotation file to the selected path
*/
private void Movesrc2tag () {
try {
Target file
File Tagfile = new file (Localzippath);
Source file multiple
for (int i = 0; i < imgpaths.size (); i++) {
String childsrc = Imgpaths.get (i). Get ("Imgpath"). ToString ();
File fold = new file (childsrc);//files to be moved
if (!tagfile.exists ())
Tagfile.mkdirs ();
File Fnew = new file (Localzippath + "//" + fold.getname ());
Fold.renameto (fnew);
Toast.maketext (
Mainactivity,
Mainactivity.getresources (). GetString (
r.string.dataexport_comment_success),
Toast.length_short). Show ();
}
} catch (Exception e) {
Toast.maketext (
Mainactivity,
Mainactivity.getresources (). GetString (
R.string.dataexport_comment_faild)
+ e.tostring (), Toast.length_short). Show ();
}
}
To explain briefly, I put the full path of the file that needs to be moved in a list.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
One of several common methods of file manipulation