skip(long): This method is available in the java.io.CharArrayReader class of Java.
Syntax:
long java.io.CharArrayReader.skip(long n) throws IOException
This method takes one argument. This method skips characters. Returns the number of characters that were skipped.
Parameters: One parameter is required for this method.
n: The number of characters to skip.
Returns: The number of characters actually skipped.
Throws:
IOException - If the stream is closed, or an I/O error occurs
Approach
Java
import java.io.CharArrayReader;import java.io.IOException;public class CharArrayReaderskip {public static void main(String[] args) throws IOException {char buf[] = { 'a', 'b', 'c', 'd' };CharArrayReader charArrayReader =new CharArrayReader(buf);long n = 10;System.out.println(charArrayReader.skip(n));charArrayReader.close();}}
Output:
4
No comments:
Post a Comment