package com.pp; import java.io.File; import java.io.IOException; public class FileRename { public static void main(String[] args) throws IOException { File file = new File("E:/excel"); if (file == null) { return; } if (file.isDirectory()) { String newName=""; String[] files = file.list(); for (int i = 0; i < files.length; i++) { File f = new File(file,files[i]); String name = f.getCanonicalPath(); newName=name.replaceAll("-", ""); f.renameTo(new File(newName)); System.out.println(newName); } } } }