Java 对文件夹的操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hanshanyeyu/article/details/52597310
1. 判断文件是否存在 不存在创建
File file = new File("e:\\test\\bin.txt");
		if(!file.exists()){
			try {
				file.createNewFile();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

2. 判断文件夹是否存在,不存在创建之
File file = new File("e:\\test1");
if(!file.exists()){
	file.mkdir();
			
		}


 
 

猜你喜欢

转载自blog.csdn.net/hanshanyeyu/article/details/52597310