2 Replies Latest reply: Aug 2, 2010 1:35 PM by thomas.behr RSS

    Problem with merging two files

    807580
      Hi, I am trying to merge two media files using FileInputStream, and FileOutputStream, but only one file is written to the output file but the size of the file is showing as combined size of both the files. Can any one tell what can be reason. Same code works fine for text files.

      File f = new File(args[0]);
      FileInputStream fin = new FileInputStream(args[0]);
      FileOutputStream fout = new FileOutputStream("C:/test2.txt", true);
      byte[] b = new byte[(int)f.length()];
      fin.read(b);
      fout.write(b);
      fin.close();

      f = new File(args[1]);
      fin = new FileInputStream(args[1]);
      b = new byte[(int)f.length()];
      fin.read(b);
      fout.write(b);

      fout.close();
      fin.close();