Summary CTO (Chang Wang Yan) File constructor

 1 import java.io.File;
 2 
 3 /**
 4  * 构建File对象
 5  * @author Allen17805272076
 6  *
 7  */
 8 public class FileDemo2 {
 9     public static void main(String[] args) {
10         String path="C:/web/workspace/IO-study/src/userImg.GIF";
11         //1、构建File对象
12         File src = new File(path);
13         System.out.println(src.length());
14         
15         //2、构建File对象
16         src=new File("C:/web/workspace/IO-study/src/","userImg.GIF");
17         System.out.println(src.length());
18         
19         //3、构建File对象
20         
21         src=new File(new File("C:/web/workspace/IO-study/src/"),"userImg.GIF");
22     }
23     
24 
25 }

 

 

Guess you like

Origin www.cnblogs.com/zwyzwy/p/11869219.html
Recommended