Java StringBufferInputStream skip() Example

StringBufferInputStream class skip() method example. This example shows you how to use skip() method.


Syntax is : public long skip(long n)
This method skips n bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. This is deprecated method.

Here is the code.
/**
 * @(#) SkipStringBufferInputStream.java
 * A class representing use of method skip() of StringBufferInputStream 
 class in java.io Package. This is deprecated class in java 1.6 API.
 * @Version  29-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class SkipStringBufferInputStream {
     public static void main(String[] args)throws Exception{

    // Create object of StringBufferInputStream class
        StringBufferInputStream obj = new StringBufferInputStream("Mahendra");
    // read() method call. This is deprecated method in java 1.6 API.
    System.out.println("First character of the buffer : "+(char)obj.read());
    System.out.println("Next character of the buffer : "+(char)obj.read());
      // skip() method call. This is deprecated method in java 1.6 API.
    long longNum = obj.skip(3);
        System.out.println("After skip "+longNum+" character. Next character is : "
    +(char)obj.read());
    }
}

Output of the program.
First character of the buffer : M
Next character of the buffer : a
After skip 3 character. Next character is : d

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US