IO流<笔记>
来源:互联网 发布:编程书 编辑:程序博客网 时间:2024/05/16 03:54
byte 1字节 8bit位 取值范围:-2^7~2^7-1
short 2字节 16bit位 取值范围:-2^15~2^15-1
int 4字节 32bit位 取值范围:-2^31~2^31-1
long 8字节 64bit位 取值范围:-2^63~2^63-1
常用的File对象的API
File file = new File("E:\\..."); file.exists(); file.mkdir(); file.mkdirs(); file.createNewFile(); file.delete(); file.isDirectory(); file.isFile(); File file2 = new File("e:\\javaio\\日记1.txt"); File file2 = new File("e:\\javaio","日记1.txt"); System.out.println(file);//file.toString()的内容 file.getAbsolutePath(); file.getName(); file.getParent();
递归目录
public static void listDirectory(File dir) throws IOException{ if(!dir.exists()){ throw new IllegalArgumentException("目录" + dir + "不存在"); } if(!dir.isDirectory()){ throw new IllegalArgumentException(dir + "不是一个目录"); }-------------------------------------------------//返回的是字符串数组 直接子的名称 不包含子目录下的内容 String[] filename = dir.list(); for (String string : filename) { System.out.println(dir + "\\" + string); }------------------------------------------------- //返回的是直接子目录(文件)的对象 File[] files = dir.listFiles();//返回的是字符串数组 直接子的名称 不包含子目录下的内容 if(files!=null && files.length>0){ for (File file : files) { if(file.isDirectory()){ //递归 listDirectory(file); }else{ System.out.println(file); } } }
0 0
- 学习笔记--IO流
- java IO流笔记
- java IO流笔记
- IO流学习笔记
- IO流 【java笔记】
- IO流学习笔记
- IO流笔记
- IO流笔记2
- IO流笔记3
- IO流笔记4
- IO流笔记
- IO流笔记01
- IO流笔记02
- java笔记 IO流
- IO流<笔记>
- 学习笔记---IO流
- IO流学习笔记
- IO流笔记
- 浅析Python运算符重载
- 开通博客,和大家分享经验
- Linux中执行shell脚本的4种方法总结
- 【jzoj4777】【灌水】【搜索】
- 工厂方法模式
- IO流<笔记>
- bootstrap-typeahead的ajax调用
- HDU 5630 Rikka with Chess(构造)
- 【51Nod1292】字符串中的最大值
- wmic的官方链接
- 下一个学习计划
- Codeforces-160B-Unlucky Ticket
- java中的浅复制与深复制
- 格雷码(分治)