Manikandan
Manikandan

Reputation: 1519

How to hide a file at runtime in java

I have Java program where I create a file called hd_details, and store the hardware details of the machine that runs the program and install count. The install count is to restrict the exe to run 2 time only. I converted that program to an exe through Launch4j. When I run the exe, the file hd_details get extracted. I need to hide the file. Any suggestion?

Upvotes: 0

Views: 347

Answers (2)

Raedwald
Raedwald

Reputation: 48702

If you want a file to both exist and "be hidden", you are wanting the file-system of the computer to do something. That puts you out of the domain of Java proper and into system dependent issues. You mentioned "an exe" so I guess you need this to work only on Windows? Or do you?

On POSIX systems a file can be anonymous (and therefore invisible) but existent by removing all hard links to it while holding it open. I do not beleive that truely invisible closed files are possible in POSIX. The ls command does not normally list files with names that begin with a dot (such as .ssh), which is used to hide configuration and state files from normal use, but seeing them is as simple as typing ls -a.

Upvotes: 0

Harry Joy
Harry Joy

Reputation: 59694

On windows you can try this:

Runtime.getRuntime().exec("attrib +H hd_details");

Upvotes: 1

Related Questions