99偷拍视频精品区一区二,口述久久久久久久久久久久,国产精品夫妇激情啪发布,成人永久免费网站在线观看,国产精品高清免费在线,青青草在线观看视频观看,久久久久久国产一区,天天婷婷久久18禁,日韩动漫av在线播放直播

java更改文件名代碼 java怎么更改文件名

java怎么修改文件名稱

public class test1

天涯ssl適用于網站、小程序/APP、API接口等需要進行數據傳輸應用場景,ssl證書未來市場廣闊!成為創新互聯建站的ssl證書銷售渠道,可以享受市場價格4-6折優惠!如果有意向歡迎電話聯系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!

{

public static void main(String[] args) {

File file=new File("D:/gai.jpg"); //指定文件名及路徑

String name="123"; //新文件名字

String filename=file.getAbsolutePath();

if(filename.indexOf(".")=0) {

filename = filename.substring(0,filename.lastIndexOf("."));

}

file.renameTo(new File(name+".jpg")); //改名

}

}

用java線程實現批量修改文件名

;?? /**??? ??? * this program TODO??? ??? * @version ??? ??? * @ausor widjan wu??? ??? */??? ??? package file;??? ??? import java io File;??? ??? import java util ArrayList;??? ??? import java util Scanner;??? ??? import ncurrent *;??? ??? 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) ??? ??? FutureInteger 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( largest pool size : + largestPoolSize) ??? ??? }??? ??? }??? ??? class ChangeName implements CallableInteger??? ??? {??? ??? public ChangeName(File directory String keywords ExecutorService pool) {??? ??? this directory = directory;??? ??? this pool = pool;??? ??? this keywords = keywords;??? ??? }??? ??? public Integer call()??? ??? {??? ??? count = ;??? ??? try??? ??? {??? ??? File[] files = directory listFiles() ??? ??? ArrayListFutureInteger》 results = new ArrayListFutureInteger》() ??? ??? for (File file : files) {??? ??? if (file isDirectory()) {??? ??? ChangeName change = new ChangeName(file keywords pool) ??? ??? FutureInteger result = pool submit(change) ??? ??? } else {??? ??? count++;??? ??? String path = file getPath() ??? ??? int index = path lastIndexOf( \\ ) ??? ??? path = path substring( index + ) ??? ??? 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(FutureInteger 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;??? ??? } lishixinzhi/Article/program/Java/gj/201311/27511

java 修改文件名

java修改文件名可以直接通過右鍵文件名“Rename”實現。

第一步:找到要修改的文件名位置。

第二步:在文件上右擊,選擇“Refactor”下的“Rename”。

第三步:輸入新文件名后,點擊“確定”即可完成修改操作。

java怎樣按規定批量修改文件名

java批量修改文件名:

public static void main(String[] args) {

updateFileNames("D:\\jjjj", "第");

}

public static void updateFileNames(String url, String index){

File file = new File(url);

//判斷文件目錄是否存在,且是文件目錄,非文件

if(file.exists() file.isDirectory()){

File[] childFiles = file.listFiles();

String path = file.getAbsolutePath();

for(File childFile : childFiles){

//如果是文件

if(childFile.isFile()){

String oldName = childFile.getName();

String newName = oldName.substring(oldName.indexOf(index));

childFile.renameTo(new File(path + "\\" + newName));

}

}

}

}

當前標題:java更改文件名代碼 java怎么更改文件名
網站路徑:http://www.yijiale78.com/article16/dodeogg.html

成都網站建設公司_創新互聯,為您提供App設計建站公司標簽優化品牌網站建設網站設計品牌網站設計

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

營銷型網站建設