Eclipse redirect Input output to file

Source: Internet
Author: User
Tags stdin

Recently in the fourth edition of the Learning algorithm, in order to use the test data given by the author Alg4-data, you need to import the data directly into the program. This is done using redirects in the author's sample code, but it's inconvenient to use redirects in Eclipse, and there's a lot of information that's added to the arguments in the run configurations in the right-click Run as. The arguments parameter. Tried many times invalid, give up. Then found in the common option there is a standard input and output, the input file selected path Click Run on the line. But after run, you can press CTRL + Z in the console to finish.

My version of Eclipse is

Version:mars.1 Release (4.5.1)
Build id:20150924-1200

If it's still not working,

Method One: Directly with the Scanner class.

Direct Read input: Scannerstdin = new Scanner (system.in); Use Crtl+z to terminate input

Read in from text: Scannerstdin = new Scanner ("file name");

while (Stdin.hasnext ()) {

int key =stdin.nextint ();

}

Method Two: After the Eclispse is compiled, execute it in the command line.
Reference: http://www.cnblogs.com/zhcncn/p/4689225.html

http://leetschau.github.io/blog/2013/01/23/125458/

Eclipse redirect Input output to file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.