uses a pair of CharArrayReaders : Char Reader Writer « File Input Output « Java






uses a pair of CharArrayReaders

  

import java.io.CharArrayReader;
import java.io.IOException;

public class CharArrayReaderDemo {
  public static void main(String args[]) throws IOException {
    String tmp = "abcdefghijklmnopqrstuvwxyz";
    int length = tmp.length();
    char c[] = new char[length];

    tmp.getChars(0, length, c, 0);
    CharArrayReader input1 = new CharArrayReader(c);
    CharArrayReader input2 = new CharArrayReader(c, 0, 5);

    int i;
    while ((i = input1.read()) != -1) {
      System.out.print((char) i);
    }

    while ((i = input2.read()) != -1) {
      System.out.print((char) i);
    }
  }
}

   
  








Related examples in the same category

1.Char Array IO
2.Demonstrate CharArrayWriter.
3.Safe UTF: 64K serialized size
4.UTF8 Reader