62,635
社区成员




/**
* 创建或者删除文件
* @param filePath
* @param fileName
* @return
* @throws IOException
*/
public boolean createAndDeleteFile(String filePath,String fileName)throws IOException
{
boolean result=false;
File file=new File(filePath,fileName);
if(file.exists())
{
file.delete();
result=true;
System.out.println("文件已经被成功删除");
}
else
{
file.createNewFile();
result=true;
System.out.println("文件已经被成功创建");
}
return result;
}
File d = new File("D:\\io\\test.txt");
d.createNewFile();
import java.io.File;
public class Test{
public static void main(String[] args) throws Exception {
File f = new File("d:/io");
f.mkdirs();
f = new File("d:/io/test.txt");
f.createNewFile();
}
}