The file operations folder for Java IO streams

Source: Internet
Author: User

http://www.verejava.com/?id=17160027381247

import java.io.File;public class Test {    public static void main(String[] args) {//       File dir=File(String pathname)  //即表示文件 又表示目录        File dir=new File("dir2/test");//        boolean mkdir()  //创建一个 一级目录        dir.mkdir();//        boolean mkdirs()  //可以创建多级目录        dir.mkdirs();//        String    getAbsolutePath()   //获得文件或者是目录的绝对路径        System.out.println(dir.getAbsolutePath());//        String    getName()  //获得文件或者是目录的 文件名        System.out.println(dir.getName());//        boolean renameTo(File dest) //重命名文件或者目录        dir.renameTo(new File("dir2/newtest"));//        boolean isDirectory() //判断是否是目录        System.out.println(dir.isDirectory());//        boolean exists()  //判断文件或者目录是否存在        System.out.println(dir.exists());//        boolean delete() //只能删除空目录        File dir3=new File("dir");        dir3.delete();        File dir4=new File("dir2");        dir4.delete();    }}

http://www.verejava.com/?id=17160027381247

File operations folder for Java IO streams

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.