title: Unable to copy PDF file using FileInputStream
body: <p>I am trying to copy a PDF file from 1 location to another, but once I run the following code, I am unable to open the PDF (it is showing the following error.)</p>
  
  <blockquote>
    <p>There was an error opening this document. The file is damaged and
    could not be repaired</p>
  </blockquote>
  
  <pre><code>public class BinaryFileTransfer {
  
      private static String INPUT_FILE = "C:\\Users\\sashwat\\Desktop\\a.pdf";
      private static String OUTPUT_FILE = "C:\\Users\\sashwat\\Desktop\\a-copy.pdf";
  
      public static void main(String args[]) throws Exception {
          InputStream is = new BufferedInputStream(new FileInputStream(INPUT_FILE));
  
          OutputStream wos = new BufferedOutputStream(new FileOutputStream(OUTPUT_FILE));
  
          int len = 0;
          byte[] brr = new byte[1000];
          while ((len = is.read(brr)) != -1) {
              wos.write(brr, 0, len);
          }
      }
  }
  </code></pre>
  
  <p>Can someone help me as to what exactly am I doing wrong?</p>