Question: I am reading a video file data in bytes and sending to another file but the received video file is not playing properly and is chattered.

Can anyone explain me why this is happening and a solution is appreciated.

My code is as follows

```
import java.io.*;

public class convert {

  public static void main(String[] args) {

    //create file object
    File file = new File("B:/music/Billa.mp4");

    try
    {
      //create FileInputStream object
      FileInputStream fin = new FileInputStream(file);

       byte fileContent[] = new byte[(int)file.length()];
       fin.read(fileContent);

       //create string from byte array
       String strFileContent = new String(fileContent);

       System.out.println("File content : ");
       System.out.println(strFileContent);

       File dest=new File("B://music//a.mp4");
       BufferedWriter bw=new BufferedWriter(new FileWriter(dest));
       bw.write(strFileContent+"\n");
       bw.flush();

    }
    catch(FileNotFoundException e)
    {
      System.out.println("File not found" + e);
    }
    catch(IOException ioe)
    {
      System.out.println("Exception while reading the file " + ioe);
    }
  }
}

```

Answer: 
Hope this also helpful for you - This can read and write a file into another file (You can use any file type to do that)

```
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class Copy {
    public static void main(String[] args) throws Exception {
        FileInputStream input = new FileInputStream("input.mp4");      //input file
        byte[] data = input.readAllBytes();
        FileOutputStream output = new FileOutputStream("output.mp4");  //output file
        output.write(data);
        output.close();
    }
}

```
```
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;

import javax.imageio.ImageIO;

public class Reader {

    public Reader() throws Exception{

        File file = new File("C:/Users/Digilog/Downloads/Test.mp4");

        FileInputStream fin = new FileInputStream(file);
        byte b[] = new byte[(int)file.length()];
        fin.read(b);

        File nf = new File("D:/K.mp4");
        FileOutputStream fw = new FileOutputStream(nf);
        fw.write(b);
        fw.flush();
        fw.close();

    }

}

```