/**
 * Copyright 2017 Kailash Dabhi (Kingbull Technology)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package omrecorder;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

/**
 * {@code Wav} is recorder for recording audio in wav format.
 *
 * @author Kailash Dabhi
 * @date 31-07-2016
 */
final class Wav extends AbstractRecorder {
  private final RandomAccessFile wavFile;

  public Wav(PullTransport pullTransport, File file) {
    super(pullTransport,file);
    this.wavFile = randomAccessFile(file);
  }

  private RandomAccessFile randomAccessFile(File file) {
    RandomAccessFile randomAccessFile;
    try {
      randomAccessFile = new RandomAccessFile(file, "rw");
    } catch (FileNotFoundException e) {
      throw new RuntimeException(e);
    }
    return randomAccessFile;
  }

  @Override public void stopRecording() {
    super.stopRecording();
    try {
      writeWavHeader();
    } catch (IOException e) {
    }
  }

  private void writeWavHeader() throws IOException {
    long totalAudioLen = new FileInputStream(file).getChannel().size();
    try {
      wavFile.seek(0); // to the beginning
      wavFile.write(new WavHeader(pullTransport.source(), totalAudioLen).toBytes());
      wavFile.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
@@ -237,21 +237,16 @@
 at%0A *%0A *
-     
  http://
@@ -281,16 +281,16 @@
 NSE-2.0%0A
+
  *%0A * Un
@@ -655,40 +655,8 @@
 le;%0A
-import java.io.FileInputStream;%0A
 impo
@@ -1034,16 +1034,17 @@
 ansport,
+ 
 file);%0A 
@@ -1573,92 +1573,8 @@
 n %7B%0A
-    long totalAudioLen = new FileInputStream(file).getChannel().size();%0A    try %7B%0A  
     
@@ -1610,18 +1610,16 @@
 ginning%0A
-  
     wavF
@@ -1670,21 +1670,21 @@
 (), 
-totalAudioLen
+file.length()
 ).to
@@ -1693,18 +1693,16 @@
 tes());%0A
-  
     wavF
@@ -1718,71 +1718,8 @@
 ();%0A
-    %7D catch (IOException e) %7B%0A      e.printStackTrace();%0A    %7D%0A
   %7D%0A

Use file length & remove try catch