【发布时间】:2014-10-02 09:08:29
【问题描述】:
我的代码:
File dir = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_DOWNLOADS );
File src = new File(dir, "test.dat");
File dst = new File(dir, "test_2.dat");
if ( src.exists() )
{
try
{
Process process = Runtime.getRuntime().exec( new String[] {"cp", "-f", src.getAbsolutePath(), dst.getAbsolutePath()} );
process.waitFor();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
此代码在三星 Galaxy S3 上有效(复制文件),但在亚马逊 Kindle Fire 上无效:
java.io.IOException:运行 exec() 时出错。命令:[cp, -f, /mnt/sdcard/Download/test.dat, /mnt/sdcard/Download/test_2.dat] 工作目录:null 环境:null
为什么会这样?以及如何在所有设备上执行此命令副本?
【问题讨论】:
-
定义“作品”。它应该做什么?
-
什么意思? (“作品”)
标签: android