How to get all the shared folders in Windows XP using Java

巧了我就是萌 提交于 2019-12-25 11:55:09

问题


How can i get all the shared folders in Windows XP in my local system using java.

Thanks


回答1:


net share   

Try executing this command in windows machine.
Here is sample how to execute commands from java code




回答2:


try {
        String line = null;
        String[] commands = new String[] { "cmd", "/C", "net share" };
        Process child = Runtime.getRuntime().exec(commands);
        InputStream ins = child.getInputStream();
        BufferedReader buffReader = new BufferedReader(
                        new InputStreamReader(ins));
        while (!(line = buffReader.readLine()).trim().equals(
                "The command completed successfully.")) {
            System.out.println(line);
             }
    } catch (Exception exp) {
    }


来源:https://stackoverflow.com/questions/3830847/how-to-get-all-the-shared-folders-in-windows-xp-using-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!