The Artima Developer Community
Sponsored Link

Java Answers Forum
Java IO - Set File Hidden

2 replies on 1 page. Most recent reply: Jan 14, 2012 3:14 AM by Javin Paul

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Sanjay Ambardar

Posts: 2
Nickname: sandy1
Registered: Mar, 2004

Java IO - Set File Hidden Posted: Mar 3, 2004 5:35 AM
Reply to this message Reply
Advertisement
Is there any way to create a HIDDEN file from java. I see in the File class I can test whether a file is hidden or not by calling method isHidden(). But is there a way to create a file from java program and is invisible in the folder.


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: Java IO - Set File Hidden Posted: Mar 5, 2004 9:29 AM
Reply to this message Reply
When you read the documentation on the method isHidden you find that the way a file is determined to be hidden is by the filename. So its a matter of naming your file when you create it. Unix hidden files just start with the period character. In Winodws you have to find a file extension that is hidden and just use that when you name it.

I set my file view option to show hidden files. So everything shows up.

A old hacker dos trick was to use a space character ascii code 20. But that is easily seen and read as well in windows.

The simplest thing is don't give it a file extension at all.

public boolean isHidden()
Tests whether the file named by this abstract pathname is a hidden file. The exact definition of hidden is system-dependent. On UNIX systems, a file is considered to be hidden if its name begins with a period character ('.'). On Microsoft Windows systems, a file is considered to be hidden if it has been marked as such in the filesystem.

Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Re: Java IO - Set File Hidden Posted: Jan 14, 2012 3:14 AM
Reply to this message Reply
Yes there is way by directly executing command using Runtime.getRuntime().exec() or using JDK7 new PATH class which allows you to set hidden attribute on file. check here for details http://javarevisited.blogspot.com/2012/01/how-to-hide-file-java-program-example.html

Flat View: This topic has 2 replies on 1 page
Topic: dos commands Previous Topic   Next Topic Topic: get Class and Method name of calling class

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use