File file = new File("C:\\work\\"); file.mkdirs(); new FileOutputStream("C:\\work\\aaa.txt"); FileOutputStream是不会自动建文件夹的