Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream iStream = new FileInputStream("c:/test.txt");
        BufferedInputStream bis = new BufferedInputStream(iStream);

        // read and print characters one by one
        System.out.println((char) bis.read());
        System.out.println((char) bis.read());
        System.out.println((char) bis.read());

        // mark is set on the input stream
        bis.mark(0);
        System.out.println((char) bis.read());

        // reset is called
        bis.reset();

        // read and print characters
        System.out.println((char) bis.read());
        System.out.println((char) bis.read());

    }
}