0

I have the following project in Intellij with the following structure

  C:.
  ├───.idea
  │   ├───copyright
  │   ├───dictionaries
  │   └───libraries
  ├───data
  ├───lib
  ├───out
  │   └───production
  │       └───Java Algorithms
  └───src

I'm trying to execute the following code

Binary Search in Gist Github

In the data folder I have two archives tinyW.txt and tinyT.txt

And in the lib folder I have the algs4 jar library, I put the link to the StdIn where I think the problem resides.

And as you can see in the gist I go BinarySearch 'Edit configurations' and in the 'Program arguments' I use

data/tinyW.txt < data/tinyT.txt

So when I Run the program, I think it keeps doing nothing but the virtual process machine is still running.

I tried to find the problem using debug, and I check that the arguments are ok, that is,

args[0] = tinyW.txt
args[1] = <
args[2] = tinyT.txt

The tinyW.txt gets parsed ok, but when the debuger gets to this line

while (!StdIn.isEmpty()) 

It does nothing and doesn't show me any available options.

I was wondering if anyone could lend a hand on how to run correctly this kind of programs in IDEA.

Thanks.

  • It is in this site http://algs4.cs.princeton.edu/code/javadoc/ left part Search for StdIn – David Cardozo Jan 24 '16 at 05:09
  • @Makoto http://introcs.cs.princeton.edu/java/stdlib/StdIn.java.html I found the javadoc – David Cardozo Jan 24 '16 at 05:16
  • Possible duplicate of [Simulate input from stdin when running a program in intellij](http://stackoverflow.com/questions/18437181/simulate-input-from-stdin-when-running-a-program-in-intellij) – heenenee Jan 25 '16 at 06:30

1 Answers1

0

IntelliJ IDEA run configurations do not support redirecting the standard input from a file. You need to either change your code so that it reads from a file directly, or run your program from the command line outside of IntelliJ IDEA.

yole
  • 92,896
  • 20
  • 260
  • 197