当我们需要将远程文件copy到本地某路径下的时候,需要在本地创建临时文件,以下代码根据路径创建临时文件:
public static void mkTempDirs(String filePath) {
File file = new File(filePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}