class Main { public static void main(String[] args) { File dir = new File("C:"); String[] children = dir.list(); if (children == null) { System.out.println( "目錄不存在或它不是一個目錄"); } else { for (int i=0; i< children.length; i++) { String filename = children[i]; System.out.println(filename); } } } }