package com.walter.test; //your package
import java.io.File;
import java.io.IOException;
public class Text {
public static void main(String[] args) {
String path ="F:\\testcode\\Index"; //所创建文件目录
File f = new File(path);
if(!f.exists()){
f.mkdirs(); //创建目录
}
String fileName = "abc.txt"; //文件名及类型
File file = new File(path,fileName);
if(!file.exists()){ //surround with try/catch
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
如何用java创建目录及文件
猜你喜欢
转载自blog.csdn.net/weixin_37704787/article/details/82182920
今日推荐
周排行