(Edited) I’m currently using Java and IntelliJ as an IDE. During a contest, I want to be able to test my code against my own inputs. Because I am only able to test my code against the inputs USACO gives me. So I want to make a file that I can run my code on. How do I make a file that I can run my Java program on? For example, if I want to test the simple:
out.println(f.readline());
I can make a file:
Hello World!
And run my program on this file, to make the program output: “Hello World!”
Ah. I fear I have not stated my question clear enough.
How can I test my code, against my own custom input? Because during the contest, I can only test my code against the input they give me. I want to be able to create my own file with my own input where I can test my code against, and my question is how to do so.
No, no, I do not mean how to do I\O for a contest. I already know how to do that. What I am asking is, how to be able to make my OWN files that I can test my code against. For testing purposes, I want to be able to make my own inputs, and not just use the inputs USACO gives me.
Can’t you just run your code on your IDE?? Alternatively, you can test your solution here. This custom invocation also gives feedback on the time it took… Does that answer your question?? Also, why do you need a file? Can’t you just write your own inputs and see if you get the right output (you can check your output by solving by hand).
If you mean how do you test your code, as jessechoe10 said, you just create your own test cases and solve by hand. Then compare what your code gives to what you got by hand.
If you don’t know how to run code in IntelliJ, the simplest way is to just right-click your main method and click run.