Java中CharArrayReader類的markSupported()方法用於檢查此CharArrayReader是否支持mark()操作。它返回一個布爾值,該狀態指示是否標記了閱讀器。
用法:
public boolean markSupported()
參數:此方法不接受任何參數
返回值:此方法返回一個布爾值,該值指示此CharArrayReader是否支持mark()操作。如果為markSupported,則返回true。否則返回false。
下麵的方法說明了markSupported()方法的用法方式:
示例1:
// Java program to demonstrate
// CharArrayReader markSupported() method
import java.io.*;
import java.util.*;
class GFG {
public static void main(String[] args)
{
try {
char[] str = { 'G', 'e', 'e', 'k', 's',
'F', 'o', 'r',
'G', 'e', 'e', 'k', 's' };
// Create a CharArrayReader instance
CharArrayReader reader
= new CharArrayReader(str);
// Check if the CharArrayReader is
// markSupported using markSupported()
System.out.println("Is CharArrayReader markSupported: "
+ reader.markSupported());
reader.close();
}
catch (Exception e) {
System.out.println(e);
}
}
}
輸出:
Is CharArrayReader markSupported: true
示例2:
// Java program to demonstrate
// CharArrayReader markSupported() method
import java.io.*;
import java.util.*;
class GFG {
public static void main(String[] args)
{
try {
char[] str = { 'G', 'E', 'E', 'K', 'S' };
// Create a CharArrayReader instance
CharArrayReader reader
= new CharArrayReader(str);
// Check if the CharArrayReader is
// markSupported using markSupported()
System.out.println("Is CharArrayReader markSupported: "
+ reader.markSupported());
reader.close();
}
catch (Exception e) {
System.out.println(e);
}
}
}
輸出:
Is CharArrayReader markSupported: true
參考: https://docs.oracle.com/javase/9/docs/api/java/io/CharArrayReader.html#markSupported–
相關用法
- Java Reader markSupported()用法及代碼示例
- Java StringReader markSupported()用法及代碼示例
- Java PushbackReader markSupported()用法及代碼示例
- Java ByteArrayInputStream markSupported()用法及代碼示例
- Java CharArrayReader mark(int)用法及代碼示例
- Java CharArrayReader close()用法及代碼示例
- Java CharArrayReader reset()用法及代碼示例
- Java CharArrayReader ready()用法及代碼示例
- Java CharArrayReader read()用法及代碼示例
- Java CharArrayReader read(CharBuffer)用法及代碼示例
- Java CharArrayReader read(char[])用法及代碼示例
- Java CharArrayReader skip(long)用法及代碼示例
- Java CharArrayReader read(char[], int, int)用法及代碼示例
- Java Java.io.CharArrayReader用法及代碼示例
- Java Java lang.Long.highestOneBit()用法及代碼示例
注:本文由純淨天空篩選整理自Code_r大神的英文原創作品 CharArrayReader markSupported() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。