public class FileSame {
public static void main(String[] args) {
String path="E:\\jar1";
File file = new File(path);
String[] strings = file.list();
String[] strings3=new String[strings.length];
char[] cs =null;
for (int i = 0; i < strings.length; ++i) {
cs = strings[i].toCharArray();
for (int j = cs.length-1; j >=0; --j) {
if (cs[j]=='5') {
cs[j]='6';
break;
}
}
strings3[i]=new String(cs);
}
String path2="E:\\jar2";
File file2 = new File(path2);
String[] strings2 = file2.list();
Arrays.sort(strings);
Arrays.sort(strings2);
Arrays.sort(strings3);
if (Arrays.equals(strings3, strings2)) {
for (int i = 0,j=0; i < strings.length&&j<strings2.length; ++i,++j) {
file=new File(path+File.separator+ strings[i]);
file2=new File(path+File.separator+ strings2[j]);
System.out.println(file.renameTo(file2));
}
}
}
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦