Friday, 30 March 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.     //InputStream is2 = is2.read(jpgByteArray);
  37.     try {
  38.         oStream.write(out.toByteArray());
  39.     } catch (IOException e) {
  40.         // TODO Auto-generated catch block
  41.         e.printStackTrace();
  42.     }
  43.    try {
  44.         oStream.writeTo(foStream);
  45.     } catch (IOException e) {
  46.         // TODO Auto-generated catch block
  47.         e.printStackTrace();
  48.     }
  49.    
  50.    }
  51.    
  52.    
  53.    
  54.    
  55. }

No comments:

Post a Comment