ITeye博客

Java创建隐藏文件

Java-Object · 2013-06-27 00:17 · Android技术 · 编程语言 · Markdown

import java.io.File;

import java.io.IOException;

 

public class 设置文件属性 {

// 执行以下代码你将看到一个属性为隐藏的文件(D:ddd.ddd)

// 请到D盘下查看

public static void main(String[] args) throws IOException {

// 创建新文件

File file = new File("D:\ddd.ddd");

 

// 删除文件并创建新文件

file.delete();

file.createNewFile();

 

// 拼dos命令

// attrib的祥细功能介绍请在DOS内输入 " attrib /? " 查看

String sets = "attrib +H "" + file.getAbsolutePath() + """;

// 输出命令串

System.out.println(sets);

// 运行命令串

Runtime.getRuntime().exec(sets);

}

}

转载自:http://tech.ddvip.com/2009-09/1253205754133387.html

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。