如何使用java隐藏文件夹 [英] How to make a folder hidden using java

查看:1163
本文介绍了如何使用java隐藏文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用java应用程序创建一个隐藏文件夹。该计划应该跨平台工作。那么如何编写一个可以创建隐藏文件夹的程序。



我尝试过使用

 文件newFile = new File(myfile); 
newFile.mkdir();

它会创建一个未隐藏的目录。



在Linux中在许多程序中,默认情况下隐藏名称以点开头的文件和文件夹 - 这样做很容易。



在Windows中,隐藏是存储在其中的特殊标志文件系统。没有用于更改它的Java API;您可以使用 Runtime.exec()来运行 attrib 命令。


I want to create a hidden folder using java application. That program should work across platform. So How to write a program which can create hidden folder.

I have tried using

File newFile = new File("myfile");
newFile.mkdir();

It creates a directory which is not hidden.

解决方案

The concept of hidden files/folders is very OS-specific and not accessible via the Java API.

In Linux, files and folders whose name begins with a dot are hidden per default in many programs - doing that is easy.

In Windows, "hidden" is a special flag stored in the file system. There is no Java API for changing it; you can use Runtime.exec() to run the attrib command.

这篇关于如何使用java隐藏文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆