java中IO简单使用
1、创建一个新文件public class FileDemo1{ File f =new File("d:\\test.txt");try{f.createNewFile();}catch(IOException){e.printStackTrace();}}有一点需要注意,如果在不同的操作系统,路径的分隔符是不一样的;

3、运行结果:pathSeparator:;separator:\对于之前创建文件的操作来说,最好的做法是使用以上的常量来表示路径分隔符2,删除指定的文件下面我只写main方法:public void main(String args[]){

5、列出指定文件夹下的全部目录;File f=new File("d:"+File.separator);//列出全部名称,啼矍囫砒返回一个字符串数组String path[]=f.list();//for循环遍历for(int i=0;i<path.length;i++){System.out.println(path[i]);}
