android 本地切割文件

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_25412055/article/details/78864842
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();
}

猜你喜欢

转载自blog.csdn.net/qq_25412055/article/details/78864842
今日推荐