Android 移动文件相关问题!急!!!

上午开始问的问题了,难道就没人会了吗?为什么我这个方法移动不了?代码是正常执行的,但是图片却没移动,而且要移动的那个图片也变成空的了。

    /**
     * 移动至指定文件夹
     * @param path 图片源完整路径
     * @param newPath 目标文件夹路径
     * @param name 图片名称(例如:aaa.jpg)
     * @return
     */
    public static boolean moveFile(String path, String newPath, String name) {
        File oldfile = new File(path);
        if (!oldfile.exists()) {
            return false;
        }
        File desfile = new File(newPath);
        if (!desfile.exists()) {
            desfile.mkdirs();
        }
        int size = 0;
        try {
            InputStream is = new FileInputStream(oldfile); // 读入原文件
            OutputStream os = new FileOutputStream(desfile.getAbsolutePath() + name);
            byte[] bs = new byte[1024];
            while ((size = is.read(bs)) != -1) {
                os.write(bs, 0, size);
                os.flush();
            }
            os.close();
            is.close();
            oldfile.delete();
            return true;
        } catch (IOException e) {
            e.printStackTrace();
            Log.e(TAG, "移动至指定文件夹异常失败");
            return false;
        }
    }

要移动的肯定为空了啊,因为你调了oldfile.delete();你应该在return true之前加上if(desfile.getAbsolutePath().equals(newPath)

OutputStream os = new FileOutputStream(desfile.getAbsolutePath() + name);
加了分隔符没?

1.你这里问题比较多;
newpath到底是文件夹名还是文件全路径名?
如果创建了这个文件夹,那么文件名后缀问题会导致该文件不存在;或者写入问题;
你应该;
把路径名newpath ,判断创建文件夹;
然后 newpath+name+文件后缀,生成文件;
然后读写可以得到正确的

唉,非常不好意思,我都不知道怎么选择了,随便吧!希望没有采纳的热心朋友包含一下!