ChararrayReader example

xiaoxiao2021-04-07  312

/ *

CharaRrayReader is an implementation of an input stream that uses arrays as a source. This class has two constructor, each requires a character array to provide a data source: ChararrayReader (char Array []) ChararrayReader (Char Array [], int Start, int Numchars) Here, Array is an input source. The second constructor created a Reader from the subset of your character array, which starts with the index specified by START, and the length is NumChars.

* /

// Demonstrate CharArrayReader.import java.io *;. Class CharArrayReaderDemo {public static void main (String [] args) throws IOException {String strTmp = "abcdefghijklmnopqrstuvwxyz"; int intLen = strTmp.length (); char c [] = new Char [intlen]; stramp.getchars (0, intlen, c, 0); ChararrayReader INPUT1 = New CharaRrayReader (C); ChararrayReader INPUT2 = New ChararrayReader (C, 0, 5); INT I; System.out.println (" INPUT1 IS: "); while (i = INPUT1.READ ())! = - 1) {system.out.Print ((char) i);} system.out.println (); system.out.println "INPUT2 IS:"); while ((i = INPUT2.READ ())! = - 1) {system.out.print ((char) i);} system.out.println ();}}

转载请注明原文地址:https://www.9cbs.com/read-132531.html

New Post(0)