四.日期时间类:
a.从1900年1月1日00:00:00为计算机起始时间,称为“历元”
例:Date d1 =new Date (5,1,25);代表:
1905(1900+5)年2(1+1)月25日
b.long time =d.getTime();和1900年的毫秒差
c.int year =d.getYear();年-1900
Int month=d.getMonth();月-1
int date =d.getDate();日
int hour=d.get Hour();小时
int minute=d.getMinute();分钟
Int second=d.getSecond();秒
int day=d.getDay();一周第几天(星期天为0)
SimpleDateFormat sdf =new SimpleDateFormat(pattern);//产生格式化对象
String formatDate =sdf.format(date);
System.out.print(formatDate);、、输出
IO流
一.概念: 通过数据流、序列化和文件系统提供系统输入和输出。 a. File(String pathname)
通过将给定路径名字符串转换为抽象路径名来创建一个新 File 实例。
b.File(String parent, String child)
根据 parent 路径名字符串和 child 路径名字符串创建一个新 File 实例。通过数据流、序列化和文件系统提供系统输入和输出。
当且仅当不存在具有此抽象路径名指定名称的文件时,不可分地创建一个新的空文件
2).public boolean mkdir()
创建此抽象路径名指定的目录。
3).public boolean mkdirs()
创建此抽象路径名指定的目录,包括所有必需但不存在的父目录
4).public boolean createNewFile()
当且仅当不存在具有此抽象路径名指定名称的文件时,不可分地创建一个新的空文件。
5)public boolean exists()
测试此抽象路径名表示的文件或目录是否存在。
6). public String getName()
返回由此抽象路径名表示的文件或目录的名称。
7).public String getParent()
返回此抽象路径名父目录的路径名字符串;如果此路径名没有指定父目录,则返回 null。
8).public File getParentFile()
返回此抽象路径名父目录的抽象路径名;如果此路径名没有指定父目录,则返回 null。
9).public String getAbsolutePath()
返回此抽象路径名的绝对路径名字符串
10).public boolean delete()
删除此抽象路径名表示的文件或目录。
11).public boolean isDire
12).public boolean isFile()
测试此抽象路径名表示的文件是否是一个标准文件。
13).public File[] listFiles()
返回一个抽象路径名数组,这些路径名表示此抽象路径名表示的目录中的文件。