Java PushbackReader markSupported()方法与示例
PushbackReader类markSupported()方法
markSupported()方法在java.io包中可用。
markSupported()方法用于检查此流是否支持mark()方法。
markSupported()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
在检查支持方法时,markSupported()方法不会引发异常。
语法:
public boolean markSupported();
参数:
它不接受任何参数。
返回值:
方法的返回类型为boolean,当此流支持mark()方法时返回true,否则返回false。
示例
//Java程序演示示例
//方法
//PushbackReader-
import java.io.*;
public class MarkSupportedOfPBR {
public static void main(String[] args) throws Exception {
Reader r_stm = null;
PushbackReader pb_r = null;
try {
//实例化Reader和PushbackReader-
r_stm = new StringReader("Java World!!!!");
pb_r = new PushbackReader(r_stm);
//通过使用markSupported()方法是
//检查此流是否支持
//mark()方法与否
boolean status = pb_r.markSupported();
System.out.println("pb_r.markSupported(): " + status);
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
//借助此块可以
//释放所有链接的必要资源
//与流
if (r_stm != null) {
r_stm.close();
if (pb_r != null) {
pb_r.close();
}
}
}
}
}输出结果
pb_r.markSupported(): false
热门推荐
10 美国护士毕业祝福语简短
11 八一祝福语简短情话句子
12 祝福语医生文案简短英文
13 离别对同事祝福语简短
14 PMP考试祝福语简短励志
15 健康祝福语长辈文案简短
16 广东考试祝福语朋友简短
17 情侣签名简短英文祝福语
18 麻将打牌祝福语简短霸气