Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileInputStream;
import java.io.IOException;
import java.io.LineNumberInputStream;

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

        byte[] buf = new byte[5];

        char c;

        FileInputStream fis = new FileInputStream("C:/test.txt");
        LineNumberInputStream lnis = new LineNumberInputStream(fis);

        int i = lnis.read(buf, 2, 3);
        System.out.println("The number of char read: " + i);

        for (byte b : buf) {
            if (b == 0)
                c = '-';
            else
                c = (char) b;

            System.out.print(c);
        }

    }
}