Basic Java Fast: File redirection on Eclipse IDE

Basic Java Fast: File redirection on Eclipse IDE


Hello everybody, welcome to the Java course
We don’t always need to print the result on the console. Instead we can print the
result on the text file. And this process is known as file redirection. How can we
achieve this process? We can see some examples here. Okay, if I simply run this
line of code. The result will be shown on the console. But if I want to show the
result on a text file, how can I do that? I can go to Run, Run configurations. And
make sure that I reach this correct Driver program under the Java
application sub-directory. And then I go to the common tab. And here I can decide
the output file to put the contents in the main method to the text file. Let me
do it again. I can choose the workspace, and then click on file redirection, ok. And
under this directory, I can create my own file name, output dot txt. And then I can
click run. Here we don’t see the result on the console. Instead we see the
result on the txt file here, which is under the FileRedirection directory, ok.
If I want to add something more into the original text file, how can I do that? Now I want to add two more lines to the
original text file. So how can I do that? I can go to Run, Run configurations,
comment tab. And it … here we have to check “append”. In this way, the new contents
coming from the two lines which are input by me shortly will be appended to the
original text file. So let me run it Yes, when I click on the text file again the
two lines are added into the original text file. So even though the main method
doesn’t contain the first line of statement called “Hello World” the output
dot txt file will still contain this sentence as the first sentence in the output
dot txt file. Why? Because I do the appending action, okay. This is the way we
write something onto a text file instead of writing it on the console. This is the
end of the video. If you have any questions about my video, feel free to leave your
comments on the comment section below the video. If you like this video, please
give me a like and please subscribe to my channel. Thank you for watching

Leave a Reply

Your email address will not be published. Required fields are marked *