贴上正确代码:你的代码本来没有什么问题的,但是只能够通过DOS下去运行,如果要在eclipse这些工具运行只能在arguments里面输入参数,谢谢采纳
import java.io.*;
import java.util.Scanner;
public class Exceptle13_1 {
public void newFolder(String newfolder) {
try {
String filepath = newfolder;
File myPath = new File(filepath);
if (!myPath.exists()) {
myPath.mkdir();
}
} catch (Exception e) {
System.out.println("新建目录存在");
e.printStackTrace();
}
}
public static void main(String[] args) {
String mynewpath = new Scanner(System.in).next();
System.out.println(mynewpath);
Exceptle13_1 createNewFolder = new Exceptle13_1();
createNewFolder.newFolder(mynewpath);
}
}