如何创建一个给定的Path路径中的文件目录及其文件

xiaoxiao2021-02-28  45

目录

Java笔记shell笔记

Java笔记

/** * 安全的创建一个文件 * - 当该文件的父目录不存在时,一并创建。 * * @param Path 创建文件的完整路径 * @return 创建的新文件File对象 * @throws IOException */ protected static File createFile(String Path) throws IOException { File file = new File(Path); File fileParent = file.getParentFile(); if (!fileParent.exists()) { fileParent.mkdirs(); } file.createNewFile(); return file; }

shell笔记

使用时间秒数+随机数的方式表示唯一标识 date +%S``echo $RANDOM

转载请注明原文地址: https://www.6miu.com/read-2624547.html

最新回复(0)