import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.charset.*;

public class BufferCharset1
{
  static public void main( String args[] ) throws Exception {
    FileInputStream fin = new FileInputStream("alphabet.txt");
    Charset charset = Charset.forName("ISO-8859-1");
    CharsetDecoder decoder = charset.newDecoder();
    FileChannel canal = fin.getChannel();
    ByteBuffer byteBuf = ByteBuffer.allocate( 10 );
    canal.read(byteBuf);
    byteBuf.flip();
    CharBuffer carBuf = decoder.decode(byteBuf);
    System.out.println("lu : "+carBuf.toString());
    byteBuf.clear();
    canal.read(byteBuf);
    byteBuf.flip();
    carBuf = decoder.decode(byteBuf);
    System.out.println("lu : "+carBuf.toString());
    byteBuf.clear();
    canal.read(byteBuf);
    byteBuf.flip();
    carBuf = decoder.decode(byteBuf);
    System.out.println("lu : "+carBuf.toString());
    fin.close();
  }
}
