Thursday, October 4, 2012

Read and wite a video in java

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class VideoTest {
    public static void main(String args[]) throws IOException {
        File file1 = new File("C:/Users/splashtechie/Pictures/test.mp4");
        FileOutputStream foStream = new FileOutputStream(file1);
        ByteArrayOutputStream oStream = new ByteArrayOutputStream();
        InputStream is2 = new FileInputStream("C:/Users/splashtechie/Videos/test.mp4");
        //InputStream is2 = rs.getBinaryStream(1);
        byte[] bytes = new byte[is2.available()];
        is2.read(bytes);
        oStream.write(bytes);
        System.out.println("writing....");
        oStream.writeTo(foStream);
       
        System.out.println("done!!!");
    }

}

No comments: