Java InputStream markSupported()方法与示例
InputStream类markSupported()方法
markSupported()方法在java.io包中可用。
的markSupported()方法被用来检查是否此流的载体mark(),reset()或没有。
markSupported()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
在检查支持方法时,markSupported()方法不会引发异常。
语法:
public boolean markSupported();
参数:
它不接受任何参数。
返回值:
方法的返回类型为boolean,当此流支持时返回truemark(),reset()否则返回false。
示例
//Java程序演示示例 
//布尔markSupported()方法
//InputStream的
import java.io.*;
public class MarkSupportedOfIS {
 public static void main(String[] args) throws Exception {
  InputStream is_stm = null;
  int val = 0;
  try {
   //实例化FileInputStream-
   is_stm = new FileInputStream("D:\\includehelp.txt");
   //通过使用markSupported()方法是
   //检查此流is_stm是否支持
   //mark()方法与否
   boolean status = is_stm.markSupported();
   System.out.println("is_stm.markSupported(): " + status);
  } catch (Exception ex) {
   System.out.println(ex.toString());
  } finally {
   //借助此块可以
   //释放所有链接的必要资源
   //与流
   if (is_stm != null) {
    is_stm.close();
   }
  }
 }
}输出结果
is_stm.markSupported(): false
