首页 > 编程语言 > 详细

Java I/O系统

时间:2019-05-12 22:59:28      阅读:223      评论:0      收藏:0      [点我收藏+]

一、File 类

1、一个File类对象,表示了磁盘上的文件或目录

2、File类提供了与平台无关的方法对磁盘上文件或目录进行操作

3、File类直接处理文件和文件系统

4、File类没有指定信息怎样从文件读取或者向文件存储

 

二、File 创建文件

public class FileTest1 {
	public static void main(String[] args) throws IOException {
		File file = new File("d:/test.txt");
		System.out.println(file.createNewFile());
				
	}
}  

显示

true  

说明创建成功。

 

三、在文件夹下创建文件

public static void main(String[] args) throws IOException {
		File file = new File("c:/abc");
		File file2 = new File(file, "hello.txt");
		System.out.println(file2.createNewFile());
				
	}

  将在abc文件夹下创建hello.txt文件

Java I/O系统

原文:https://www.cnblogs.com/linlf03/p/10853950.html

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