title: java.io.FileNotFoundException: Temp (Access is denied)
body: <p>I have no idea why this is happening. The purpose of my code is to compare two files, and I got it from my programming book. This is my code: </p>
  
  <pre><code>import java.io.*;
  
  class CompFiles {
  public static void main(String args[])
  {
      int i=0, j=0;
  
  // First make sure that both files have been specified.
  if(args.length !=2 ) {
    System.out.println("Usage: CompFiles f1 f2");
    return;
  }
  
  // Compare the files.
  try
      {
          FileInputStream f1 = new FileInputStream(args[0]);
           FileInputStream f2 = new FileInputStream(args[1]);
  
    // Check the contents of each file.
    do {
      i = f1.read();
      j = f2.read();
      if(i != j) break;
    } while(i != -1 &amp;&amp; j != -1);
  
    if(i != j)
      System.out.println("Files differ.");
    else
      System.out.println("Files are the same.");
  } catch(IOException exc) {
    System.out.println("I/O Error: " + exc);
     }
   }
  }
  </code></pre>
  
  <p>I compiled the code like this: <code>javac CompFiles.java</code> then the book told me to copy the files to a temp file using this command: <code>java CompFiles CompFiles.java temp</code>. The output is <code>java.io.FileNotFoundExceptions: Temp(Access is dined)</code>.
   I am not using any IDEs. Thanks for any answers.</p>