Java examples for Native OS:Shell Command
hide File via shell command
//package com.java2s; import java.io.IOException; public class Main { public static void main(String[] argv) throws Exception { String path = "java2s.com"; hide(path);//from w ww . j ava 2 s. c o m } public static void hide(String path) throws InterruptedException, IOException { String command = "attrib +h " + path; execSystemCommon(command); } private static void execSystemCommon(String command) throws IOException, InterruptedException { try { Process proc = Runtime.getRuntime().exec(command); proc.waitFor(); } catch (IOException e) { throw e; } catch (InterruptedException exp) { throw exp; } } }