欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
java讀取文件夾下的所有文件夾和文件 - 夢(mèng)幻e家人 - BlogJava

java讀取文件夾下的所有文件夾和文件

package com.borland.samples.welcome;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.File;

public class ReadFile {
  public ReadFile() {}

  /**
   * 刪除某個(gè)文件夾下的所有文件夾和文件
   * @param delpath String
   * @throws FileNotFoundException
   * @throws IOException
   * @return boolean
   */
  public static boolean deletefile(String delpath) throwsFileNotFoundException,
      IOException {
    try {

      File file = new File(delpath);
      if (!file.isDirectory()) {
        System.out.println("1");
        file.delete();
      }
      else if (file.isDirectory()) {
        System.out.println("2");
        String[] filelist = file.list();
        for (int i = 0; i < filelist.length; i++) {
          File delfile = new File(delpath + "\\" + filelist[i]);
          if (!delfile.isDirectory()) {
            System.out.println("path=" + delfile.getPath());
           System.out.println("absolutepath=" + delfile.getAbsolutePath());
            System.out.println("name=" + delfile.getName());
            delfile.delete();
            System.out.println("刪除文件成功");
          }
          else if (delfile.isDirectory()) {
            deletefile(delpath + "\\" + filelist[i]);
          }
        }
        file.delete();

      }

    }
    catch (FileNotFoundException e) {
      System.out.println("deletefile()   Exception:" + e.getMessage());
    }
    return true;
  }

  /**
   * 刪除某個(gè)文件夾下的所有文件夾和文件
   * @param delpath String
   * @throws FileNotFoundException
   * @throws IOException
   * @return boolean
   */
  public static boolean readfile(String filepath) throwsFileNotFoundException,
      IOException {
    try {

      File file = new File(filepath);
      if (!file.isDirectory()) {
        System.out.println("文件");
        System.out.println("path=" + file.getPath());
        System.out.println("absolutepath=" + file.getAbsolutePath());
        System.out.println("name=" + file.getName());

      }
      else if (file.isDirectory()) {
        System.out.println("文件夾");
        String[] filelist = file.list();
        for (int i = 0; i < filelist.length; i++) {
          File readfile = new File(filepath + "\\" + filelist[i]);
          if (!readfile.isDirectory()) {
            System.out.println("path=" + readfile.getPath());
           System.out.println("absolutepath=" + readfile.getAbsolutePath());
            System.out.println("name=" + readfile.getName());
           
          }
          else if (readfile.isDirectory()) {
            readfile(filepath + "\\" + filelist[i]);
          }
        }

      }

    }
    catch (FileNotFoundException e) {
      System.out.println("readfile()   Exception:" + e.getMessage());
    }
    return true;
  }

  public static void main(String[] args) {
    try {
      readfile("D:/file");
      //deletefile("D:/file");
    }
    catch (FileNotFoundException ex) {
    }
    catch (IOException ex) {
    }
    System.out.println("ok");
  }

}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
java 文件操作集
Java操作文件、目錄
java file.listFiles()按文件名稱(chēng)、日期、大小排序
在java中如何遍歷某個(gè)路徑下的所有文件夾和文件
java開(kāi)發(fā)之——遍歷文件夾的兩種方式
java刪除文件及目錄
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久