Java Note 11__file class/file class jobs

Source: Internet
Author: User

/*** File class: Create, delete, rename, get path, create time, etc., is the only action class related to the file itself*/ Public classMain { Public Static voidMain (string[] args) {//File.separator represents a delimiterFile F1 =NewFile ("C:" + file.separator + "fuck" + file.separator + "JavaTest1.txt"); String S1= File.pathseparator;//Path delimiterSystem.out.println (File.separator + "" +S1); BooleanB1 = F1.exists ();//whether the file existsSystem.out.println (B1); if(!B1) {            Try {                BooleanBT1 = F1.createnewfile ();//Create a fileSystem.out.println (BT1); } Catch(IOException e) {e.printstacktrace (); }} System.out.println (F1.delete ()); //Deleting Files//System.out.println (""); Shortcut: Hit Sout, then press the TAB keySystem.out.println (F1.getparent ());//get the top-level path to the fileSystem.out.println (F1.isdirectory ());//determine if it is a directoryFile F2=NewFile ("C:" + file.separator + "fuck" +file.separator); String[] fname= F2.list ();//List all file names in a folder         for(String i:fname) System.out.println (i); file[] Files= F2.listfiles ();//lists all the files in the file, returned as an array of files         for(File i:files) System.out.println (I.getname () + "" +i.length ()); File f3=NewFile ("C:\\fuck\\javatest1"); System.out.println (F3.mkdir ()); //Create a folderF3.delete (); System.out.println (F3.renameto (NewFile ("C:\\fuck\\javatest2"));// Renaming    }}

Java note 11__file class/file class jobs

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.