Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.*;

public class Main {
    public static void main(String[] args) {
        String s = "tutorial from java2s.com";

        Reader reader = new StringReader(s);

        try {
            // read the first five chars
            for (int i = 0; i < 5; i++) {
                char c = (char) reader.read();

                // skip a char every time
                reader.skip(1);

                System.out.println(c);
            }
            reader.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}