Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.*;
import java.nio.CharBuffer;

public class Main {

    public static void main(String[] args) {

        String s = "tutorial from java2s.com";

        CharBuffer cb = CharBuffer.allocate(100);

        Reader reader = new StringReader(s);

        try {
            reader.read(cb);

            cb.flip();

            // print the char buffer
            System.out.println(cb.toString());

            reader.close();

        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}