Java CharArrayReader markSupported() Example

CharArrayReader class markSupported() method example. This example shows you how to use markSupported() method.


Syntax is : public boolean markSupported()
This method tells whether this stream supports the mark() operation, which it does.

Here is the code.
/**
 * @(#) MarkSupportedCharArrayReader.java
 * A class representing use of method markSupported() of CharArrayReader 
 class in java.io Package.
 * @Version  31-May-2008
 @author   Rose India Team
 */
import java.io.*;
public class MarkSupportedCharArrayReader {
  public static void main(String[] argsthrows IOException{
        
    char[] arrBuffer = {'M','A','H','E','N','D','R','A'};
     System.out.print("given character buffer is : ");
     for (int i=0;i<arrBuffer.length ;i++ ){
       System.out.print(arrBuffer[i]);
     }
        // Create a new CharArrayReader.
         CharArrayReader obj = new CharArrayReader(arrBuffer);
     // markSupported() method call.
         boolean bool = obj.markSupported();
       System.out.println("\nSpecified char array is mark supported..? "+bool);
    }
}
/* Another constructor of class CharArrayReader:-
    public CharArrayReader(char[] buf, int offset, int length)
  Description:
    Creates a CharArrayReader from the specified array of chars.
    The resulting reader will start reading at the given offset. The total 
  number of char values that can be read from this reader will be either 
  length or buf.length-offset, whichever is smaller.

  Parameters:
        buf - Input buffer (not copied)
        offset - Offset of the first char to read
        length - Number of chars to read 
  Throws:
        IllegalArgumentException - If offset is negative or greater than 
    buf.length, or if length is negative, or if the sum of these two values
    is negative. */ 

Output of the program.
given character buffer is : MAHENDRA
Specified char array is mark supported..? true

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

HOME | COPYRIGHT | CONTACT US