Check if a file is hidden in Java

Object Oriented ProgrammingJava Programming Java8

<p style="">The java.io.File class provides useful methods on file. This example shows how to check a file hidden or not by using the file.isHidden() method of File class.</p><h2>Example</h2><pre class="prettyprint notranslate">import java.io.File; public class Main { &nbsp; &nbsp;public static void main(String[] args) { &nbsp; &nbsp; &nbsp; File file = new File(&quot;C:/java.txt&quot;); &nbsp; &nbsp; &nbsp; System.out.println(file.isHidden()); &nbsp; &nbsp;} }</pre><h2 class="result notranslate">Result</h2><p>The above code sample will produce the following result (if the file &quot;java.txt&quot; exists and is hidden in &#39;C&#39; drive).</p><pre class="result notranslate">true</pre>
raja
Updated on 18-Jun-2020 13:15:46

Advertisements