I have been learning Java for the past couple of months now and while I have gotten to grips with just about everything, input and output redirection are causing me somewhat of a problem. The book I am using (Introduction to Java Programming, Ninth Edition) brings up the concept fairly early on and references it on and off throughout the book and while I have managed to get away with not knowing exactly how to do it, I feel it will set me back considerably soon if I don't get to grips with it soon.
So, my question is how do I do it? So far I understand that input redirection is done by
java ClassName < input.txt
And Output by
java ClassName > Output.txt
in the Command Prompt. This is basically all the book gives in respect to the topic. Yet I've had limited success with this. Such that I could get it to work by fully directing it to the folder where both ClassName.class and input.txt is saved. For input redirection to work, do both the class file and .txt file have to be situated in the same folder?
If so what are the commands for use in cmd to change the folders in which it is directed towards?
Then for output redirection i have been unsuccessful in getting this to work, does output redirection create a .txt file in which it will store my output data or do i need to create that .txt file before I can use output redirection?
For reference I have organised my work through the book into chapters so that each program created will be easy to find in the eventuality that I need to. they are stored as followed:
C:\Users\Lenovo\Documents\NetBeansProjects\LearningJava\src\Chapter2ElementaryProgramming
for Chapter 2 respectively.
This is my first post on StackOverflow so any advice is appreciated and I apologies if I'm unclear in what I'm asking as I am not yet proficient in Java and what everything means as of yet