返回列表 發帖
  1. import java.io.File;

  2. public class Asdf {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.         File file = new File("C:\\My");
  6.         String f[] = file.list();
  7.         for(int i=0; i<f.length; i++)
  8.             {
  9.                   System.out.println(f[i]);
  10.             }
  11.         }

  12. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

  1. import java.io.File;
  2. import java.io.IOException;

  3. public class Asdf {

  4.         public static void main(String[] args) {

  5.         File file = new File("C://a//b//c//test");
  6.         
  7.         if(!file.exists()){
  8.                
  9.                 String path = file.getParentFile().getPath();
  10.                 File newfile = new File(path+"//test");
  11.                 newfile.getParentFile().mkdirs();
  12.                 try {
  13.                         newfile.createNewFile();
  14.                 } catch (IOException e) {
  15.                         // TODO 自動產生的 catch 區塊
  16.                         e.printStackTrace();
  17.                 }
  18.                
  19.         }
  20.         
  21.    }

  22. }
複製代碼
我是眾神之王XXX  I love you
0000000000

TOP

返回列表