李采潭一级毛片高清中文字幕,亚洲欧洲久久精品,人人插人人舔,91视频专区,杨幂不雅视频bt,美女视频 新婚之夜,日本美女在线视频网站免费

技術(shù)中心

這里象征著我們的態(tài)度和能力

用java線程實(shí)現(xiàn)批量修改文件名
作者:中國(guó)IT實(shí)驗(yàn)室    來(lái)源:中國(guó)IT實(shí)驗(yàn)室    發(fā)布時(shí)間:2012-09-15      瀏覽次數(shù):13547
分享到:
歡迎進(jìn)入Java社區(qū)論壇,與200萬(wàn)技術(shù)人員互動(dòng)交流 >>進(jìn)入
    /**
   
    * this program TODO
   
    * @version 1.0 2012-9-1
   
    * @ausor widjan wu
   
    */
   
    package file;
   
    import java.io.File;
   
    import java.util.ArrayList;
   
    import java.util.Scanner;
   
    import java.util.concurrent.*;
   
    public class ChangeFileName
   
    {
   
    public static void main(String[] args)
   
    {
   
    Scanner in = new Scanner(System.in);
   
    System.out.print(“Enter base directory :”);
   
    String directory = in.nextLine();
   
    System.out.print(“Enter key words:”);
   
    String keywords = in.nextLine();
   
    ExecutorService pool = Executors.newCachedThreadPool();
   
    ChangeName change = new ChangeName(new File(directory), keywords, pool);
   
    Future result = pool.submit(change);
   
    try {
   
    System.out.println(result.get() + “files were changed”);
   
    } catch (ExecutionException e) {
   
    e.printStackTrace();
   
    } catch (InterruptedException e) {
   
    }
   
    pool.shutdown();
   
    int largestPoolSize = ((ThreadPoolExecutor) pool)。getLargestPoolSize();
   
    System.out.println(“l(fā)argest pool size :” + largestPoolSize);
   
    }
   
    }
   
    class ChangeName implements Callable
   
    {
   
    public ChangeName(File directory, String keywords, ExecutorService pool) {
   
    this.directory = directory;
   
    this.pool = pool;
   
    this.keywords = keywords;
   
    }
   
    public Integer call()
   
    {
   
    count = 0;
   
    try
   
    {
   
    File[] files = directory.listFiles();
   
    ArrayList   
    for (File file : files) {
   
    if (file.isDirectory()) {
   
    ChangeName change = new ChangeName(file, keywords, pool);
   
    Future result = pool.submit(change);
   
    } else {
   
    count++;
   
    String path = file.getPath();
   
    int index1 = path.lastIndexOf(“”);
   
    path = path.substring(0, index1+1);
   
    System.out.println(path);
   
    String oldName = file.getName();
   
    String fileType = oldName.substring(oldName.lastIndexOf(“.”));
   
    String newFName = path + keywords + count + fileType;
   
    file.renameTo(new File(newFName));
   
    }
   
    }
   
    for(Future result:results)
   
    {
   
    try
   
    {
   
    count +=result.get();
   
    }catch(ExecutionException e)
   
    {
   
    e.printStackTrace();
   
    }
   
    }
   
    }catch(InterruptedException e)
   
    {
   
    }
   
    return count;
   
    }
   
    private File directory;
   
    private String keywords;
   
    private ExecutorService pool;
   
    private int count;
   
    }
4000-880-989
(24小時(shí)熱線)
聯(lián)系客服
微信公眾號(hào)

官方公眾號(hào)

小程序

?2008-2022 CORPORATION ALL Rights Reserved. 昆明奧遠(yuǎn)科技有限公司版權(quán)所有 滇ICP備09003328號(hào)-1 滇公網(wǎng)安備 53011102000818號(hào) 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證號(hào):滇B2-20110045
昆明那家網(wǎng)絡(luò)公司好,新媒體運(yùn)營(yíng),網(wǎng)站優(yōu)化,網(wǎng)絡(luò)推廣,網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),網(wǎng)站推廣,云南網(wǎng)站公司,昆明新媒體公司,云南網(wǎng)紅主播,昆明SEO公司,昆明網(wǎng)站建設(shè),昆明網(wǎng)絡(luò)推廣,昆明網(wǎng)站優(yōu)化,昆明網(wǎng)站推廣,紅河網(wǎng)站建設(shè),大理網(wǎng)絡(luò)公司,曲靖網(wǎng)絡(luò)公司,麗江網(wǎng)站設(shè)計(jì),昭通網(wǎng)絡(luò)公司,保山大數(shù)據(jù)服務(wù),智慧高速建設(shè),智慧校園服務(wù),云南IDC服務(wù)商,網(wǎng)絡(luò)安全測(cè)評(píng),等保測(cè)評(píng),網(wǎng)站關(guān)鍵詞排名優(yōu)化服務(wù),服務(wù)客戶盡超2000余家,一切盡在奧遠(yuǎn)科技,服務(wù)電話:13888956730