以下代码在我用 标记的地方给了我一个错误~~~~ ~~~~
。它说:
标记的语法错误,错误的构造
有人可以帮我吗?
如果您帮助我解决此错误,我将非常感激,或者给我另一个文件夹复制代码!
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File srcFolder = new File(Environment.getExternalStorageDirectory()
+ "/folder/");
File destFolder = new File(
"/data/data/folder");
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
~~~~public void~~~~ copyFolder(srcFolder, destFolder);
{
if(src.isDirectory()){
//if directory not exists, create it
if(!dest.exists()){
dest.mkdir();
Log.i("Status : ", "Directory copied from "
+ srcFolder + " to " + destFolder);
}
//list all the directory contents
String files[] = src.list();
for (String file : files) {
//construct the src and dest file structure
File srcFile = new File(src, file);
File destFile = new File(dest, file);
//recursive copy
copyFolder(srcFile,destFile);
}
}else{
//if file, then copy it
//Use bytes stream to support all file types
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest);
byte[] buffer = new byte[1024];
int length;
//copy the file content in bytes
while ((length = in.read(buffer)) > 0){
out.write(buffer, 0, length);
}
in.close();
out.close();
Log.i("Status : ","File copied from " + srcFolder + " to " + destFolder);
}
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}