1. 程式人生 > >android 本地切割檔案

android 本地切割檔案

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(); }