Java BufferedReader markSupported()方法与示例
BufferedReader类markSupported()方法
markSupported()方法在java.io包中可用。
markSupported()方法用于检查此BufferedReader是否支持mark()和reset()方法。
markSupported()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
在检查支持方法时,markSupported()方法不会引发异常。
语法:
public boolean markSupported();
参数:
它不接受任何参数。
返回值:
该方法的返回类型是布尔值,当此流支持它返回truemark()和reset()方法,否则返回false。
示例
//Java程序演示示例
//方法
//BufferedReader-
import java.io.*;
public class MarkSupportedBR {
public static void main(String[] args) throws Exception {
//打开文本文件
//FileInputStream-
FileInputStream fis = new FileInputStream("e:/includehelp.txt");
//实例化InputStreamReader-
InputStreamReader inp_r = new InputStreamReader(fis);
//实例化BufferedReader-
BufferedReader buff_r = new BufferedReader(inp_r);
//检查是否此流
//buff_r支持mark(),reset()
//是否
boolean status = buff_r.markSupported();
System.out.println("buff_r.markSupported(): " + status);
//检查是否此流
//inp_r支持mark(),reset()
//是否
status = inp_r.markSupported();
System.out.println("inp_r.markSupported(): " + status);
fis.close();
inp_r.close();
buff_r.close();
}
}输出结果
buff_r.markSupported(): true inp_r.markSupported(): false
热门推荐
10 祝孙辈生日祝福语简短
11 恋人跨年祝福语大全简短
12 考大学敬酒简短祝福语
13 开工投产大吉祝福语 简短
14 偶然结婚祝福语朋友简短
15 感谢学长学姐祝福语简短
16 戏精的祝福语简短
17 我要结婚祝福语简短
18 婚前女儿生日祝福语简短