博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java FileDescriptor valid()方法与示例
阅读量:2538 次
发布时间:2019-05-11

本文共 1867 字,大约阅读时间需要 6 分钟。

FileDescriptor类valid()方法 (FileDescriptor Class valid() method)

  • valid() method is available in java.io package.

    valid()方法在java.io包中可用。

  • valid() method is used to check whether this FileDescriptor object is valid or not.

    valid()方法用于检查此FileDescriptor对象是否有效。

  • valid() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    valid()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • valid() method does not throw an exception at the time of checking the status of an object.

    在检查对象状态时, valid()方法不会引发异常。

Syntax:

句法:

public boolean valid();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is boolean, it returns true when this FileDescriptor is valid otherwise it returns false.

方法的返回类型为boolean ,如果此FileDescriptor有效,则返回true ,否则返回false

Example:

例:

// Java program to demonstrate the example // of boolean valid() method of FileDescriptorimport java.io.*;public class ValidOfFD {
public static void main(String[] args) throws Exception {
FileInputStream is_stm = null; try {
// Instantiates FileInputStream is_stm = new FileInputStream("D:\\includehelp.txt"); // By using getFD() method is to get // the file descriptor FileDescriptor file_des = is_stm.getFD(); System.out.println("is_stm.getFD(): " + file_des); // By using valid() method is to check // whether the file descriptor is valid or // not boolean status = file_des.valid(); System.out.println("is_stm.valid(): " + status); } catch (Exception ex) {
System.out.println(ex.toString()); } finally {
// with the help of this block is to // free all necessary resources linked // with the stream if (is_stm != null) {
is_stm.close(); } } }}

Output

输出量

is_stm.getFD(): is_stm.valid(): true

翻译自:

转载地址:http://jpvzd.baihongyu.com/

你可能感兴趣的文章
hdu-5596 GTW likes gt(模拟+优先队列)
查看>>
codeforces 711A A. Bus to Udayland(水题)
查看>>
python在不同层级目录import模块的方法
查看>>
Git的使用--如何将本地项目上传到Github
查看>>
MySQL连接localhost失败
查看>>
networkComms 通信框架之 消息处理器
查看>>
Java基础——详尽说明try-catch-finally的用法
查看>>
报错处理——# Creating Server TCP listening socket *:6379: bind: Address already in use
查看>>
锦囊5-斐波那契数列
查看>>
关于T_SQL中声明变量类型的基础知识。
查看>>
Orthanc+OHIF DICOM Viewer最佳Dicom解析、在线浏览实践指南(解决方案)
查看>>
封装条形码MaHelper
查看>>
AfxMessageBox详细使用说明
查看>>
[SDOI2016]储能表——数位DP
查看>>
java 反射 getClass()
查看>>
nginx 命令
查看>>
清理SharePoint 2010的SQL Server 2008 R2日志数据库的方法
查看>>
实现鼠标放上高亮显示,鼠标移出显示原来的颜色
查看>>
mysql -数据库
查看>>
充电器
查看>>