首页 > 其他 > 详细

CreateFileDemo

时间:2015-05-26 20:48:59      阅读:167      评论:0      收藏:0      [点我收藏+]
import java.io.File;
import java.io.IOException;

public class CreateFileDemo {
	public static void main(String[] args) {
		try {
			File file = new File("D:\\newfile.txt");
			/*
			 * If file gets created then the createNewFile() method would return
			 * true or if the file is already present it would return false
			 */
			boolean fvar = file.createNewFile();
			if (fvar) {
				System.out.println("File has been created successfully");
			} else {
				System.out.println("File already present at the specified location");
			}
		} catch (IOException e) {
			System.out.println("Exception Occurred:");
			e.printStackTrace();
		}
	}
}

  

http://beginnersbook.com/2014/01/how-to-create-a-file-in-java/

 

CreateFileDemo

原文:http://www.cnblogs.com/lnas01/p/4531546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!