党员出国Java实现复制并修改部分⽂件后缀名
阳江是几线城市public class Test {
烤翅做法
public static String DIR = "e:\\Test\\java";//需要复制的源⽂件地址
public static String DESTDIR = "e:\\Test\\aaa";//拷贝后存放的地址
public static void main(String[] args) throws Exception {如果国宝会说话观后感
System.out.println("开始");
traverFolder(DIR);
System.out.println("结束");
}
public static void copy(InputStream in, OutputStream out) throws Exception {
byte[] buf = new byte[1024];
int len = 0;
/*读取⽂件内容并写⼊⽂件字节流中*/
while((len = in.read(buf))!=-1) {
out.write(buf, 0, len);
}
}
public static void traverFolder(String path) throws Exception {
File file = new File(path);
if (ists()) {
File[] files = file.listFiles();
if (files.length == 0) {蝇营狗苟的意思
System.out.AbsolutePath() + " 空⽂件夹!");
return;
} el {
月瓜for (File file2 : files) {
if (file2.isDirectory()) {
//如果是⽂件夹创建⽂件夹
File str = new AbsolutePath().toString().replace(DIR, DESTDIR));
str.mkdir();
//递归查找该⽂件夹⾥⾯的⽂件婚姻法律
AbsolutePath());
}el {
医疗质量管理体系
FileInputStream fis = new FileInputStream(file2);