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.pswp.cn/news/542127.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542127.shtml
英文地址,請注明出處:http://en.pswp.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. …