- package bbs.istak.org.tw;
- import java.io.File;
- import java.io.IOException;
- public class main {
- private static int number;
- private static File f;
- public static void main(String args[]) throws IOException
- {
- f = new File("D:\\a\\b\\c\\Test.txt");
- String str[] = f.list();
- String path = f.getPath();
- File file =S(path);
- }
- public static File S(String path)
- {
- if(!f.exists())
- {
- if(number==0)
- {
- f.getParentFile().mkdirs();
- try {
- f.createNewFile();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return S(f.getPath());
- }else
- {
- return f;
- }
- }
複製代碼 |