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 is = new FileInputStream("C:/test.txt");

        // input stream is converted to buffered input stream
        BufferedInputStream bis = new BufferedInputStream(is);

        // read until a single byte is available
        while (bis.available() > 0) {
            // skip single byte from the stream
            bis.skip(1);

            // read next available byte and convert to char
            char c = (char) bis.read();
            System.out.print(c);
        }
    }
}