Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedReader;
import java.io.StringReader;
import java.nio.CharBuffer;

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

        String s = "from java2s.com";

        StringReader sr = new StringReader(s);

        // create new buffered reader
        BufferedReader br = new BufferedReader(sr);

        // Destination source is created
        CharBuffer target = CharBuffer.allocate(s.length());

        // ready is invoked to test if character stream is ready
        if (br.ready()) {
            br.read(target);
        }
        System.out.print(target.array());

    }
}