Java error in making file through console

﹥>﹥吖頭↗ 提交于 2019-12-01 21:47:27

mkdir isn't a standalone executable you can launch as a separate process - it's a command that the Windows command shell understands.

So you could run cmd.exe /c mkdir ...:

Runtime.getRuntime().exec("cmd.exe /c mkdir c:\\Users\\Nick\\test");

Or:

Runtime.getRuntime().exec(
    new String[] { "cmd.exe", "/c" "mkdir" "c:\\Users\\Nick\\test"});

... but I'd still recommend just using File.mkdir instead... why call out to an external process when you can do it within Java? (If you're going to specify an odd requirement, it helps to give some more context on it...)

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