指定路径删除文件

指定路径删除文件

根据文件路径删除指定文件夹

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();
		}
	}

版权声明:本文为Luojun904原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。