符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
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")); //改名
}
}
; /** * 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修改文件名可以直接通过右键文件名“Rename”实现。
第一步:找到要修改的文件名位置。
第二步:在文件上右击,选择“Refactor”下的“Rename”。
第三步:输入新文件名后,点击“确定”即可完成修改操作。
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));
}
}
}
}