Java数据流之File

时间:2014-06-18 21:22:31   收藏:0   阅读:348

  @Test
    public  void fileTest() {
        //创建File 对象
        File file=new File("hell.txt");
        //获取文件名
        System.out.println(file.getName());
        //访问文件的绝对路径
        System.out.println(file.getAbsolutePath());
        //为文件对象重命名
        file.renameTo(new File("hellWord.txt"));
        //判断文件是否真的存在
        if(!file.exists()){
            try {
                //如果不存在,创建
                file.createNewFile();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        System.out.println(file.getName());
        System.out.println("古典风格公司");
        
    }

Java数据流之File,布布扣,bubuko.com

原文:http://www.cnblogs.com/liuquande/p/3790363.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!