Java文件类boolean isHidden()方法(带示例)

文件类boolean isHidden() (File Class boolean isHidden())

  • This method is available in package java.io.File.isHidden().

    软件包java.io.File.isHidden()中提供了此方法。

  • This method is used to check whether the file is hidden or not.

    此方法用于检查文件是否隐藏。

  • The return type of this method is Boolean i.e. The value of this method is true or false if it returns true that means the file is hidden else return false so the file is not hidden.

    此方法的返回类型为布尔值,即,如果该方法的返回值为true,则该值为true或false,这意味着该文件已隐藏;否则返回false,因此该文件未被隐藏。

  • This method may raise an exception(i.e. Security Exception) if the write access is not given to the file.

    如果未授予文件写入权限,则此方法可能会引发异常(即Security Exception)。

Syntax:

句法:

    boolean isHidden(){
}

Parameter(s):

参数:

We don't pass any object as a parameter in the method of the File.

我们不会在File方法中将任何对象作为参数传递。

Return value:

返回值:

The return type of this method is Boolean i.e. it returns true then in that case given file is hidden else returns false so the file is not hidden.

此方法的返回类型为布尔值,即返回true,则在这种情况下给定文件被隐藏,否则返回false,因此文件未被隐藏。

Java程序演示isHidden()方法的示例 (Java program to demonstrate example of isHidden() method)

// import the File class because we will use File class methods
import java.io.File;
// import the Exception class because it may raise an 
// exception when working with files
import java.lang.Exception;
public class ToCheckFileHidden {
public static void main(String[] args) {
try {
// Specify the path of file and we use double slashes to 
// escape '\' character sequence for windows otherwise 
// it will be considerable as url.
File file1 = new File("C:\\Users\\computer clinic\\OneDrive\\Articles\\myjava.txt");
File file2 = new File("C:\\Users\\computer clinic\\OneDrive\\Articles\\myjava1.txt");
// By using isHidden() is used to check whether the file 
// is hidden or not . It returns true because given file is hidden.
if (file1.isHidden())
System.out.println("This file " + " " + file1.getName() + " " + "is hidden");
else
System.out.println("This file" + " " + file1.getName() + " " + "is not hidden");
// By using isHidden() is used to check whether the 
// file is hidden or not. It returns false because given file 
// is not hidden.
if (file2.isHidden())
System.out.println("This file " + " " + file2.getName() + " " + "is hidden");
else
System.out.println("This file " + " " + file2.getName() + " " + "is not hidden");
} catch (Exception e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}

Output

输出量

D:\Programs>javac ToCheckFileHidden.java
D:\Programs>java ToCheckFileHidden
This file  myjava.txt is hidden
This file  myjava1.txt is not hidden

翻译自: https://www.includehelp.com/java/file-class-boolean-ishidden-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542127.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

js导出的xlsx无法打开_js-xlsx 导出表格至excel

引入js文件下载地址:链接: https://pan.baidu.com/s/1gdOl1HnTrM5mZgPgd5qeDQ 提取码: c8js导入4个js文件js/xlsx.extendscript.js,js/xlsx.full.min.js,js/export.js,js/jszip.js,js/xlsx-style/xlsx.full.min.js其中 js/xlsx-style/xlsx.full.min.js 是表格样式的…

oracle sql 语句如何插入全年日期?

为什么80%的码农都做不了架构师&#xff1f;>>> oracle sql 语句如何插入全年日期&#xff1f; create table BSYEAR (d date); insert into BSYEAR select to_date(20030101,yyyymmdd)rownum-1 from all_objects where rownum < to_char(to_date(20031231,…

getparent_Java文件类字符串getParent()方法(带示例)

getparent文件类字符串getParent() (File Class String getParent()) This method is available in package java.io.File.getParent(). 软件包java.io.File.getParent()中提供了此方法。 This method is used to return the parent of the given file object(i.e In case of f…

python—while循环、字符串

1. while循环&#xff1a; while 条件满足&#xff1a;满足条件执行的语句 else:不满足条件执行的语句while 死循环 只要满足 while的条件永远为真&#xff0c;就会进入无限循环 while True:print(一直循环)while嵌套 \t &#xff1a;在控制台输出一个制表符&#xff0c;协助…

java基础——java基本运算

java基本运算 转载于:https://www.cnblogs.com/zhouj/p/6132535.html

【Java】MybatisPlus

MybatisPlus MybatisPlus是在mybatis基础上的一个增强型工具。它对mybatis的一些操作进行了简化&#xff0c;能够提高开发的效率。 springboot整合了mybatis之后&#xff0c;其实已经非常方便了&#xff0c;只需要导入mybatis的包后&#xff0c;在配置文件中编写数据源信息&a…

机器人总动员拟人后_WALL·E 机器人总动员——又是一部让名字耽误的高分电影...

WALLE 机器人总动员(2008)导演&#xff1a; 安德鲁斯坦顿简单&#xff0c;却惹人落泪的动画电影。名字叫做机器人总动员&#xff0c;说实话&#xff0c;这部电影高高的挂在豆瓣的排行榜上&#xff0c;但却因为名字被我总是忽视掉&#xff0c;我好像就是这么肤浅的人呀~电影是由…

Java DataInputStream readBoolean()方法(带示例)

DataInputStream类readBoolean()方法 (DataInputStream Class readBoolean() method) readBoolean() method is available in java.io package. readBoolean()方法在java.io包中可用。 readBoolean() method is used to check whether this stream read the boolean value or n…

python—列表

1 . 什么是列表&#xff1a; 列表形如[‘saf’,‘sf’,5,哈哈‘]&#xff0c;是一个可以储存任意数据类型的集合。需要注意的是&#xff0c;列表和数组不同&#xff0c;数组是储存统一数据类型的集合。 创建一个列表&#xff1a; zero_li [ ] #建立一个空列表li [ ‘http’…

更新SQL Server实例所有数据库表统计信息

引出问题 自从上次菜鸟为老鸟解决了《RDS SQL SERVER 解决中文乱码问题》问题&#xff0c;老鸟意犹未尽&#xff0c;决定再想个招来刁难刁难菜鸟&#xff1a;“我最近做T-SQL性能调优的时候&#xff0c;经常发现执行计划中的统计信息不准确&#xff0c;导致SQL Server查询性能低…

职工考勤管理信息系统数据库课设_数据库课程设计--职工考勤管理信息系统

目录1概述........................................................................................................................................ 11.1设计背景..................................................................................................…

python—元组

1 . 元组的创建&#xff1a; 1 . 简介 &#xff1a;元组与列表类似&#xff0c;可以存储任意数据类型。不同之处在于元组的元素不能修改。属于不可变数据类型&#xff0c;没有增删改。 2 . 创建一个元组&#xff1a; t ([1, 2, 3], ssh, True) #和列表不同是&#xff0c;元组…

java clock计时_Java Clock类| systemDefaultZone()方法与示例

java clock计时Clock Class systemDefaultZone()方法 (Clock Class systemDefaultZone() method) systemDefaultZone() method is available in java.time package. systemDefaultZone()方法在java.time包中可用。 systemDefaultZone() method is used to get the current inst…

从0开始搭建SQL Server AlwaysOn 第四篇(配置异地机房节点)

从0开始搭建SQL Server AlwaysOn 第四篇&#xff08;配置异地机房节点&#xff09; 第一篇http://www.cnblogs.com/lyhabc/p/4678330.html第二篇http://www.cnblogs.com/lyhabc/p/4682028.html第三篇http://www.cnblogs.com/lyhabc/p/4682986.html第四篇http://www.cnblogs.com…

vue 左侧菜单隐藏_vue.js 左侧二级菜单显示与隐藏切换的实例代码

vue点击切换显示隐藏*{padding: 0;margin: 0;font-size: 14px;}ul{width: 200px;height: auto;}h2{background: green;border: 1px solid #fff;color: #fff;height: 30px;line-height: 30px;text-indent: 24px;}h3{background: #999;height: 24px;line-height: 24px;border: 1p…

Java LocalDateTime类| 带示例的getMinute()方法

LocalDateTime类getMinute()方法 (LocalDateTime Class getMinute() method) getMinute() method is available in java.time package. getMinute()方法在java.time包中可用。 getMinute() method is used to get minute-of-hour field value from this date-time object. getM…

python—集合

1. 集合的概念和建立&#xff1a; Python中的集合和数学中的集合类似&#xff0c;可以保存不重复的元素。它有可变集合&#xff08;set&#xff09;和不可变集合&#xff08;frozenset&#xff09;两种。 集合是不重复的并且无序的序列。 集合创建可以使用{}以及set()的方式。…

第十九天

今天是学习js的第三天&#xff0c;已经感觉脑内存不够用了。 想想后续还有这么多Php的课程要学习&#xff0c;真心有点怕怕的。希望以后时间过的慢一些&#xff0c;让我好好的掌握这门技术吧。 另外&#xff0c;学习js里面还有好多的应用需要自己去掌握&#xff0c;我希望能够通…

弹性理论法研究桩基受力计算公式_竖向荷载下群桩的承载力分析

竖向荷载下群桩的承载力分析桩基础在工程建设当中得到广泛地应用,从安全性上考虑,对群桩承载力的研究尤为重要。文章结合一工程实例,根据现场取得的静载荷试验数据,(本文共4页)阅读全文>>墙体顶部斜裂缝问题一直是困扰设计和施工人员的重要课题,以往的研究往往将这种斜裂…

Java LocalDate类| getChronology()方法与示例

LocalDate类getChronology()方法 (LocalDate Class getChronology() method) getChronology() method is available in java.time package. getChronology()方法在java.time包中可用。 getChronology() method is used to return the IsoChronology of this LocalDate object. …