✎
编程开发网
首页
C语言
C++
面试
Linux
函数
Windows
数据库
下载
搜索
当前位置:
首页
->
AI编程基础
->
JAVA
java创建文件和目录(三)
2014-11-24 09:26:26
·
作者:
·
浏览:
4
标签:
java
创建
文件
目录
}
else
{
System.out.println(
"创建目录"
+ destDirName +
"失败!"
);
return
false
;
}
}
public
static
String createTempFile(String prefix, String suffix, String dirName) {
File tempFile =
null
;
if
(dirName ==
null
) {
try
{
//在默认文件夹下创建临时文件
tempFile = File.createTempFile(prefix, suffix);
//返回临时文件的路径
return
tempFile.getCanonicalPath();
}
catch
(IOException e) {
e.printStackTrace();
System.out.println(
"创建临时文件失败!"
+ e.getMessage());
return
null
;
}
}
else
{
File dir =
new
File(dirName);
//如果临时文件所在目录不存在,首先创建
if
(!dir.exists()) {
if
(!CreateFileUtil.createDir(dirName)) {
System.out.println(
"创建临时文件失败,不能创建临时文件所在的目录!"
);
&nb
首页
上一页
1
2
3
4
5
6
下一页
尾页
3
/6/6