指定路径删除文件
根据文件路径删除指定文件夹
public static void delFile(String filePathAndName) {
try {
String filePath = filePathAndName;
filePath = filePath.toString();
java.io.File myDelFile = new java.io.File(filePath);
myDelFile.delete();
} catch (Exception e) {
log.error("删除文件失败");
e.printStackTrace();
}
}
/**
* 根据文件编码创建文件
* @param path
* @param content
* @param fileCode
*/
public static void createFile(String path,String content,String fileCode){
try {
FileOutputStream fos = new FileOutputStream(path);
OutputStreamWriter osw = new OutputStreamWriter(fos, fileCode);
osw.write(content);
osw.flush();
} catch (Exception e) {
e.printStackTrace();
}
}