慕运维1137616
public FileOperate() {}/*** 新建目录* @param folderPath String 如 c:/fqf* @return boolean*/public void newFolder(String folderPath) {try {String filePath = folderPath;filePath = filePath.toString();java.io.File myFilePath = new java.io.File(filePath);if (!myFilePath.exists()) {myFilePath.mkdir();}}catch (Exception e) {System.out.println("新建目录操作出错");e.printStackTrace();}}/*** 新建文件* @param filePathAndName String 文件路径及名称 如c:/fqf.txt* @param fileContent String 文件内容* @return boolean*/public void newFile(String filePathAndName, String fileContent) {try {String filePath = filePathAndName;filePath = filePath.toString();File myFilePath = new File(filePath);if (!myFilePath.exists()) {myFilePath.createNewFile();}FileWriter resultFile = new FileWriter(myFilePath);PrintWriter myFile = new PrintWriter(resultFile);String strContent = fileContent;myFile.println(strContent);resultFile.close();}catch (Exception e) {System.out.println("新建目录操作出错");e.printStackTrace();}}