title: Redirection and Piping
body: <p>I am a beginner in java and taking the course <em>Algorithm</em>, which is provided by Princeton. I am stuck at <em>redirection and piping</em> on page 40 in chapter 1.</p>
  
  <p>I use notepadd++ with nppexec to run java, and my execute is written as</p>
  
  <pre><code>NPP_SAVE
  javac -encoding UTF-8 "$(FULL_CURRENT_PATH)"
  echo
  echo ==========编译成功后开始运行========== 
  java -cp "$(CURRENT_DIRECTORY);D:\Program Files\java\jdk\lib\algs4.jar" "$(NAME_PART)" 
  </code></pre>
  
  <p>However when I use redirection symbol > and &lt; such as</p>
  
  <pre><code>NPP_SAVE
  javac -encoding UTF-8 "$(FULL_CURRENT_PATH)"
  echo
  echo ==========编译成功后开始运行========== 
  java -cp "$(CURRENT_DIRECTORY);D:\Program Files\java\jdk\lib\algs4.jar" "$(NAME_PART)" largeW.txt &lt; largeT.txt
  </code></pre>
  
  <p>the program doesn't work. So I think symbol > and &lt; may be used in cmd, and I want to know how to redirect with nppexec.</p>
  
  <p>Any advice is helpful. Thank you. </p>
  
  <hr>
  
  <p>This example is from the book on page 9:</p>
  
  <pre><code>import edu.princeton.cs.algs4.*;
  import java.util.*;
  
  public class BinarySearch 
  {
      public static int rank(int key, int[] a)
      {
         int lo = 0;
         int hi = a.length - 1;
         while (lo &lt;= hi)
         {
              int mid = lo + (hi - lo) / 2;
              if      (key &lt; a[mid]) hi = mid - 1;
              else if (key &gt; a[mid]) lo = mid + 1;
              else return mid;
         }
         return -1;
      }
  
     public static void main(String[] args) 
     {
          In in = new In("G:\\java\\1.1\\binarysearch\\BinarySearch.txt");
          int[] whitelist = in.readAllInts();
          Arrays.sort(whitelist);
  
         while (!StdIn.isEmpty()) 
         {
              int key = StdIn.readInt();            
              if (BinarySearch.rank(key, whitelist)!= -1)              StdOut.println("here it is\n");
             else                                             StdOut.println("where it is\n");
         }
      }
    }
  </code></pre>
  
  <p>Execute of nppexec is </p>
  
  <pre><code>NPP_SAVE
  javac -encoding UTF-8 "$(FULL_CURRENT_PATH)"
  echo
  echo ==========编译成功后开始运行========== 
  java -cp "$(CURRENT_DIRECTORY);D:\Program Files\java\jdk\lib\algs4.jar" "$(NAME_PART)" largeW.txt &lt; largeT.txt
  </code></pre>
  
  <p>The largeW.txt and largeT.txt have some integers in them.</p>
  
  <p>However this execute doesn't read two txts.</p>