设置文件只读、存档、隐藏等属性
Scanner scan=new Scanner(System.in);
System.out.println("请输入想要设置的属性");
String status=scan.nextLine();
//创建命令
StringBuilder command=new StringBuilder("attrib ");
if(status.equals("只读属性")){
command.append("+R ");
}
if(status.equals("存档属性")){
command.append("+A ");
}
if(status.equals("系统属性")){
command.append("+S ");
}
if(status.equals("隐藏属性")){
command.append("+H ");
}
//增加文件路径
command.append("F:\\1.txt");
//执行命令
try {
Runtime.getRuntime().exec(command.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}