开发者

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 开发者_如何学JAVAthe 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?


On windows you can try this:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜