1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      java代碼更改文件名稱 修改java文件名

      Java能修改文件夾的名字嗎

      package?script;

      公司主營業(yè)務(wù):網(wǎng)站制作、做網(wǎng)站、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出賓陽免費做網(wǎng)站回饋大家。

      import?java.io.File;

      import?java.io.IOException;

      public?class?Realname?{

      public?static?void?main(String[]?args)?throws?IOException?

      {

      File?oldFile?=?new?File("d:/PMS");

      if(!oldFile.exists())

      {

      oldFile.createNewFile();

      }

      System.out.println("修改前文件名稱是:"+oldFile.getName());

      String?rootPath?=?oldFile.getParent();

      System.out.println("根路徑是:"+rootPath);

      File?newFile?=?new?File(rootPath?+?File.separator?+?"PMSTmp");

      System.out.println("修改后文件名稱是:"+newFile.getName());

      if?(oldFile.renameTo(newFile))?

      {

      System.out.println("修改成功!");

      }?

      else?

      {

      System.out.println("修改失敗");

      }

      }

      }

      原來寫的例子~~~希望能采納。

      java怎么修改文件名稱

      File file=new File("D:\\abc.java");

      if(file.exists())

      {

      file.renameTo(new File("d:\\123.txt"));

      }

      java怎樣按規(guī)定批量修改文件名

      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線程實現(xiàn)批量修改文件名

      ;?? /**??? ??? * 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修改文件后綴名

      以下程序?qū)崿F(xiàn)的功能是批量修改文件后綴:

      import java.io.*;

      /**

      * JAVA實現(xiàn)的批量更改文件后綴名的程序。

      *

      * @author rommnn

      */

      public class ExtBatchRename {

      /**

      * 修改程序。br

      * 內(nèi)部遞歸調(diào)用,進行子目錄的更名

      *

      * @param path

      * 路徑

      * @param from

      * 原始的后綴名,包括那個(.點)

      * @param to

      * 改名的后綴,也包括那個(.點)

      */

      public void reName(String path, String from, String to) {

      File f = new File(path);

      File[] fs = f.listFiles();

      for (int i = 0; i fs.length; ++i) {

      File f2 = fs[i];

      if (f2.isDirectory()) {

      reName(f2.getPath(), from, to);

      } else {

      String name = f2.getName();

      if (name.endsWith(from)) {

      f2.renameTo(new File(f2.getParent() + "/" + name.substring(0, name.indexOf(from)) + to));

      }

      }

      }

      }

      public static void main(String[] args) {

      ExtBatchRename rf = new ExtBatchRename();

      rf.reName("d:/", ".jsp", ".html");

      }

      }


      當(dāng)前標(biāo)題:java代碼更改文件名稱 修改java文件名
      分享鏈接:http://www.ef60e0e.cn/article/hgjsdh.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        武川县| 沈丘县| 宜兴市| 会昌县| 禹城市| 阳信县| 鸡东县| 富顺县| 同仁县| 蒲城县| 基隆市| 循化| 湘乡市| 隆昌县| 平南县| 丹寨县| 新泰市| 开原市| 怀来县| 库车县| 和林格尔县| 铁岭市| 肥城市| 安阳县| 伊金霍洛旗| 临湘市| 连南| 乌拉特中旗| 桃源县| 剑川县| 金门县| 越西县| 天全县| 禄丰县| 峨边| 师宗县| 荥阳市| 汝阳县| 合山市| 龙泉市| 兴化市|