imp imp public class ChangeI2U { public static void main(String[] args) throws UnsupportedEncodingException { File path = new File("/home/hezhihan/.aMule/Incoming");//电驴下载后的地方 File[] files = path.listFiles(); System.out.println("path:"+path.getPath()+" file(s):"+files.length); for(int i=0; i<files.length; i++) { File file = files[i]; String oldName = file.getName(); String newName = new String(oldName.getBytes("ISO8859-1"),"UTF-8");//就这句话值钱 if(file.renameTo(new File(path.getPath()+'/'+newName))) { System.out.println(oldName+"-->"+newName+",success!"); } else { System.out.println(oldName+"-->"+newName+",faild!"); } } } } |
评论