Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilterOutputStream;
import java.io.OutputStream;

public class Main {
    public static void main(String[] args) throws Exception {

        OutputStream os = new FileOutputStream("C://test.txt");
        FilterOutputStream fos = new FilterOutputStream(os);

        fos.write(65);

        // forces byte contents to written out to the stream
        fos.flush();

        // create output streams
        FileInputStream fis = new FileInputStream("C://test.txt");

        // read byte
        int i = fis.read();

        // convert integer to characters
        char c = (char) i;

        System.out.print("Character read: " + c);
        fos.close();
        fis.close();
    }
}