package cn.lijun.demo3;

import java.io.File;
import java.io.IOException; // 创建文件功能 如果文件已经存在 不再创建
public class FileDemo2 {
public static void main(String[] args) throws IOException {
fun3();
}
//删除
public static void fun3(){
File file1 =new File("c:\\baixiaolong\\b.txt");
boolean b = file1.delete();
System.out.println(b); }
//创建目录
public static void fun2() throws IOException{
File file =new File("c:\\baixiaolong");
boolean m = file.mkdirs();
System.out.println(m);
File file1 =new File("c:\\baixiaolong\\b.txt");
boolean s = file1.createNewFile();
System.out.println(s);
}
public static void fun() throws IOException{
File file =new File("c:\\a.txt");
boolean b = file.createNewFile();
System.out.println(b);
} }

File的创建的更多相关文章

  1. 关于Java里面File类创建txt文件重复???

    private JButton getOpenButton() { if (openButton == null) { openButton = new JButton(); openButton.s ...

  2. JAVA File的创建及相对路径绝对路径

    http://blog.sina.com.cn/s/blog_9386f17b0100w2vv.html JAVA File的创建及相对路径绝对路径 (2011-12-09 08:27:56) 转载▼ ...

  3. Java中File类创建文件

    只需要调用该类的一个方法createNewFile(),但是在实际操作中需要注意一些事项,如判断文件是否存在,以及如何向新建文件中写入数据等. import java.io.*; public cla ...

  4. File类创建删除功能的方法和File类遍历(文件夹)目录功能

    File类创建删除功能的方法 -public boolean createNewFile():当且仅当具有该名称的文件尚不存在时,创建一个新的空文件 -public boolean delete(): ...

  5. File类创建删除功能的方法和File类遍历目录功能

    File类创建删除功能的方法 public boolean createNewFile();当且仅当具有该名称的文件尚不存在的时候,创建一个新的空文件 public boolean delete(); ...

  6. C#使用File.Create()创建文件后资源被占用

    由于文件被占用不能读写,所以报错“另一个程序正在使用此文件进程无法访问” 解决方法是在创建文件后立即Dispose掉 File.Create(path).Dispose();

  7. Java IO 之 File 的创建、重命名与遍历

    File表示存储设备上的一个文件或目录,使用方式查看API即可,比较简单 package org.zln.io.file; import java.io.File; /** * Created by ...

  8. sls语法:创建file,创建文件夹

    http://blog.kukafei520.net/html/2014/942.html /tmp/aaa.txt: file.managed /tmp/salt_test: file.direct ...

  9. File.Create创建文件后,需要释放资源

    if (!File.Exists(SavePath)) { File.Create(SavePath).Close(); }

随机推荐

  1. LeetCode:152_Maximum Product Subarray | 最大乘积连续子数组 | Medium

    题目:Maximum Product Subarray Find the contiguous subarray within an array (containing at least one nu ...

  2. .net mvc 基类属性覆盖问题

    一,问题是这样的 我使用.net mvc设计架构时, 为了方便大家的获取UserInfo信息, 把UserInfo对象,放在了自定义的基类BaseController中, 二,问题出现了 我发觉多个人 ...

  3. 异步、+回调机制、线程queue、线程Event、协程、单线程实现遇到IO切换

    # from concurrent.futures import ProcessPoolExecutor,ThreadPoolExecutor # import requests # import o ...

  4. MT【290】内外圆求三角最值

    求$\sqrt{\dfrac{5}{4}-\sin x}+2\sqrt{\dfrac{9}{4}+\cos x-\sin x}$的最小值. 提示:$\sqrt{\dfrac{5}{4}-\sin x} ...

  5. 概率DP自学

    转自https://blog.csdn.net/zy691357966/article/details/46776199 zy691357966的blog 有关概率和期望问题的研究 摘要 在各类信息学 ...

  6. [NOIp2008] 双栈排序 (二分图染色 + 贪心)

    题意 给你一个长为 \(n\) 的序列 \(p\) ,问是否能够通过对于两个栈进行 push, pop(print) 操作使得最后输出序列单调递增(即为 \(1 \cdots n\) ),如果无解输出 ...

  7. Hdoj 1392.Surround the Trees 题解

    Problem Description There are a lot of trees in an area. A peasant wants to buy a rope to surround a ...

  8. module 'sign.views' has no attribute 'search_name'

    百度找到如下链接 http://lovesoo.org/python-script-error-attributeerror-module-object-has-no-attribute-solve- ...

  9. 使用template

    1.放置html片段模板 <script id="tpl" type="text/html"> <p>$title</p>& ...

  10. POJ2411 铺地砖 Mondriaan's Dream

    Mondriaan's Dream Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15962   Accepted: 923 ...