package com.file;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class updateFile {
public static int time = 0;
public static void main(String[] args) {
String filePath = "D:\\test\\";
iteratorFile(filePath);
System.out
.println("**********************************************************");
System.out.println("total:Update " + time + " files");
}
public static void iteratorFile(String filePath) {
File file = new File(filePath);
File[] files = file.listFiles();
for (int i = 0; files != null && i < files.length; i++) {
if (files[i].isDirectory()) {
iteratorFile(files[i].getAbsolutePath().replace('\\', '/'));
} else if (files[i].isFile()) {
String file_name = files[i].getAbsolutePath()
.replace('\\', '/');
updateFile(new File(file_name));
}
}
}
public static void updateFile(File file) {
if (file.getName().length() > 0) {
try {
int index = file.getAbsolutePath().lastIndexOf('\\') + 1;
String fileName = file.getName();
File file1 = new File(file.getAbsolutePath()
.substring(0, index)
+ fileName + "_bakj");
System.out
.println("**********************************************************");
System.out.println(file.getAbsolutePath());
BufferedReader br = new BufferedReader(new InputStreamReader(
new FileInputStream(file)));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file1)));
String line = null;
while ((line = br.readLine()) != null) {
if (line.indexOf("C:") != -1 || line.indexOf("c:") != -1) {
System.out.println(line);
}
bw.write(line.replace("c:", "D:").replace("C:", "D:")
+ "\n");
}
time++;
bw.flush();
bw.close();
br.close();
file.delete();
file1.renameTo(new File(file.getAbsolutePath().substring(0,
index)
+ fileName));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
分享到:
相关推荐
update file for my online examination
pac.txt
FTP远程文件同步更新程序 V2.1.0.0Fileupdate
文件上传过程中的jar包含common-io.jar和common-fileupdate.jar
EOS 60D / EOS 60Da 固件更新,版本1.1.2 [Windows] 最近更新 : 14-Nov-2016 发行编号 : 0400283505 详细信息 固件版本1.1.2包含了以下修正和改进: 校正了相机在搭载EF-S 18-135mm f/3.5-5.6 IS USM或EF 70-300mm ...
文件上传下载所用jar包common-fileupdate-1.2.1.jar common-io-1.4.jar
The profiles.xml file is used to identify the files in the update.app file. Every file in the update.app has a sequence or type, which is also shown in the list. Those sequences or types are used to ...
打开index.jsp输入other update file 保存后,index.jsp变成红色的感叹号 此时右键没有add实际上是工具帮add,然后commit和push ethan用户pull下来,发现index.jsp里有了other update file 5.冲突解决 有冲突的话,...
1.Added: Organize - Batch redirect shortcuts, which helps update file paths for shortcuts when files are moved. 2.Added: Edit - Syntax highlight, which helps highlight source code snippets by syntax ...
Open update file failed please check if the update file exist=打开文件失败,请检查升级文件是否存在! Open Version file fail=打开版本文件失败 Download:=下载进度: Restart the device, are you sure?=设备...
navigation update file
filemanger_update.zip
DELL UPDATE FILE R410
cadence 16.3 安装后出现can not find allegro env file.doc cadence 16.3 安装后出现can not find allegro env file.doc
下载地址:ed2k://|file|cn_visual_studio_premium_2013_with_update_5_x86_dvd_6815741.iso|5549494272|561EF218E48FECBBC04781A86860D00C|/ Visual Studio Professional 2013 with Update 5 (x86) – DVD ...
J-LINK V10 update file pack
File size: 8.86 GB File type: iso Name: VMware-VCSA-all-7.0.3-18700403.iso SHA256SUM: d1478ee9dd40bbb4445bd15ce221aea7c7f352eaf2d2f24b4c893aeceeec24b5 VMware vCenter Server Appliance Update ...
-n Don't update file; display results on stdout. -m Force MD5 encryption of the password (default). -d Force CRYPT encryption of the password. -p Do not encrypt the password (plaintext). -s Force...
Ubuntu18.04/Ubuntu20.04 安装ROS的rosdep update错误问题 下载rosdep.zip 把压缩文件解压到/opt文件夹下 修改命令sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py 把68行...