what can I add below this to make the code print everything

what can I add below this to make the code print everything on the txt file (\"originial.txt\") as an output ?

public class toread
{
public static void main(String[] args) {

System.out.println( \" I am going to read from a file \" );
System.out.println( \"here is the text \" );
  

Scanner inputStream = null;

try {
inputStream =
new Scanner( new FileInputStream(\"original.txt\"));

}

catch (FileNotFoundException e) {
System.out.println(\" File can not be found or open\");
System.exit(0);

}

Solution

public class toread
{
    public static void main(String[] args) {

        System.out.println( \" I am going to read from a file \" );
        System.out.println( \"here is the text \" );
      

        Scanner inputStream = null;

        try {
            inputStream =
                new Scanner( new FileInputStream(\"original.txt\"));

while (inputStream.hasNextLine()) {
                String line = inputStream.nextLine();
                System.out.println(line);

            }
            inputStream.close()

        }

        catch (FileNotFoundException e) {
            System.out.println(\" File can not be found or open\");
            System.exit(o);

        }

what can I add below this to make the code print everything on the txt file (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site