android 本地切割文件

来源:互联网 发布:域名价值 编辑:程序博客网 时间:2024/06/06 21:38
public static void splitFile(String path, int length, List<File> list) throws IOException{    InputStream is = new FileInputStream(path);    int len=0;    byte[] buff = new byte[length];    int i = 1;    while((len=is.read(buff))!=-1){        String filePath = Environment.getExternalStorageDirectory().getAbsolutePath()                + "/testmp4/video-" + i + ".mp4.tmp";        RandomAccessFile raf = new RandomAccessFile(filePath, "rw");        raf.write(buff,0,len);        raf.close();        list.add(new File(filePath));        i++;    }    is.close();}