0

I've also caught this problem, but not solved under your advise. It's still prompt the same error:

as I've saw in

File contains a path separator.

The problem cause by :

if (isValidMediaFile && (dir != null) ) {
    boolean bFile = dir.exists();
    Log.i(TAG,"file flag " + bFile);
    if(!bFile){
        dir.mkdirs();
        //Runtime.getRuntime().exec("cp " + f + " " + f);
    }
    Log.i(TAG, "dir= " + dir.getPath());
    try {
        String file = 
                srcfile.substring(srcfile.lastIndexOf("/")+1, 
                        srcfile.length());
        File dstfile = new File(
                dir.getAbsolutePath() + "/" + file);
        Log.i(TAG, "dst =" + dstfile);
        if(!dstfile.exists()){
            dstfile.createNewFile();
        }
        //copyFile(srcfile, dstfile);
        //FileInputStream in = context.openFileInput(srcfile);

        File sfile = context.getFileStreamPath(srcfile);
        FileInputStream in = new FileInputStream(sfile);

        BufferedInputStream bi =  new BufferedInputStream(in);

        FileOutputStream out = context.openFileOutput(dstfile.getName(), 
                Context.MODE_PRIVATE);
        BufferedOutputStream bo = new BufferedOutputStream(out);

        byte[] b = new byte[8192];
        int len;
        while( (len = bi.read(b))!= -1) {
            bo.write(b, 0,len);
        }
        out.flush();

        bi.close();
        bo.close();
        in.close();
        out.close();                    
    } catch (IOException e) {
        // TODO: handle exception
        e.printStackTrace();
    }               
}

the log messages is : java.lang.IllegalArgumentException: File /data/epay/share/Download/test280.mp4 cotains a path separator at android.app.ContextImpl.makeFilename(ContextImpl.java:1682) at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:541)

4

0 回答 0