Saturday, April 7, 2012

VideoFileReadingAndCoping


  1. package com.lkr.properties;
  2. import java.io.ByteArrayOutputStream;
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. public class VideoFileReadingAndCoping
  9. {
  10.    public static void main(String[] args)
  11.    {   
  12.     File videofile = new File("D:\\video\\MELT.MPG");
  13.     FileInputStream fileInputStream = null;
  14.     try {
  15.         fileInputStream = new FileInputStream(videofile);
  16.     } catch (FileNotFoundException e) {
  17.         // TODO Auto-generated catch block
  18.         e.printStackTrace();
  19.     }
  20.     try {
  21.         while (fileInputStream.available()>0) {
  22.             out.write(fileInputStream.read());
  23.         }
  24.     } catch (IOException e) {
  25.         // TODO Auto-generated catch block
  26.         e.printStackTrace();
  27.     }
  28.     File file1 = new File("D:\\video\\LKR.MPG");
  29.     FileOutputStream foStream = null;
  30.     try {
  31.         foStream = new FileOutputStream(file1);
  32.     } catch (FileNotFoundException e) {
  33.         // TODO Auto-generated catch block
  34.         e.printStackTrace();
  35.     }
  36.     ByteArrayOutputStream oStream = new ByteArrayOutputStream();
  37.     //InputStream is2 = is2.read(jpgByteArray);
  38.     try {
  39.         oStream.write(out.toByteArray());
  40.     } catch (IOException e) {
  41.         // TODO Auto-generated catch block
  42.         e.printStackTrace();
  43.     }
  44.    try {
  45.         oStream.writeTo(foStream);
  46.     } catch (IOException e) {
  47.         // TODO Auto-generated catch block
  48.         e.printStackTrace();
  49.     }
  50.    
  51.    }
  52.    
  53.    
  54.    
  55.    
  56. }

No comments:

Post a Comment