• Post Reply Bookmark Topic Watch Topic
  • New Topic

how can i hide existing files in a computer using java

 
kim ban
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, I have been having a problem in finding the best method in th JDK which can enable me to hide files in the system. the method which i can locate are for checking whether the file is hiden and the delete() method. can you please help me with the code to hide files in java.
thanks.
 
Avyaya Avi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Code to hide the files"? In the sense that you wish to access the client machine and hide the files by changing the attributes???

I presume that this is not possible without varying implications.

You can not change the attributes of the files.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Avyaya Avi wrote:You can not change the attributes of the files.

You can, using the setXXX methods of File. You can't change the hidden attribute though, and the reason is quite clear: for some operating systems* it's not a real attribute. For instance, under Linux files are hidden if their name starts with a dot. Changing a file to be hidden or not would involve renaming the file, and that's not always possible.

Of course Sun could have added added a method that returns a boolean like the other setXXX methods. It could then call renameTo if needed. They didn't however, so you can't change the hidden "attribute".


* It could perhaps be file system dependant instead of OS dependant, but the same applies: the behaviour is not always the same.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!