Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;

public class Main {
    public static void main(String[] argv) throws Exception {
        Charset charset = Charset.forName("ISO-8859-1");
        CharsetDecoder decoder = charset.newDecoder();
        CharsetEncoder encoder = charset.newEncoder();

        ByteBuffer bbuf = encoder.encode(CharBuffer.wrap("a string"));

        CharBuffer cbuf = decoder.decode(bbuf);
        String s = cbuf.toString();
    }
}