标签:指定 [] class int print tor path 文件 workspace
separator & pathSeparator
1 import java.io.File; 2 3 public class Separator { 4 public static void main(String[] args) { 5 System.out.println(File.separator); 6 System.out.println(File.separatorChar); 7 System.out.println(File.pathSeparator); 8 System.out.println(File.pathSeparatorChar); 9 } 10 }
---- ---- ---- ---- ---- ---- ---- ----
构造方法(Constructor)
以字节为单位,输出指定文件的大小。
1 import java.io.File; 2 3 public class Constructor { 4 public static void main(String[] args) { 5 File src = null; 6 7 // 1. File(File parent, String child) 8 src = new File(new File("E:/Java/workspace/IO_Study01"), "StarSky.jpg"); 9 System.out.println(src); 10 System.out.println(src.length() + " bytes"); 11 System.out.println(); 12 13 // 2. File(String pathname) 14 src = new File("E:/Java/workspace/IO_Study01/StarSky.jpg"); 15 System.out.println(src); 16 System.out.println(src.length() + " bytes"); 17 System.out.println(); 18 19 // 3. File(String parent, String child) 20 src = new File("E:/Java/workspace/IO_Study01", "StarSky.jpg"); 21 System.out.println(src); 22 System.out.println(src.length() + " bytes"); 23 System.out.println(); 24 25 // 4. File(URI uri) 26 } 27 }
标签:指定 [] class int print tor path 文件 workspace
原文地址:https://www.cnblogs.com/Satu/p/10012686.html