19)Using byte streams, write a program to both read from and write to files.

PHOTO EMBED

Mon Jul 08 2024 06:15:35 GMT+0000 (Coordinated Universal Time)

Saved by @varuntej #java

import java.io.*;

public class FileExample {
    static FileInputStream fis;

    public static void main(String[] args) {
        try {
            fis = new FileInputStream("example.txt");

            int data;
            while ((data = fis.read()) != -1) {
                System.out.print((char) data);
            }

            fis.close();
        } catch (IOException io) {
            System.out.println("Caught IOException: " + io.getMessage());
        }
    }
}
content_copyCOPY