大家好,又见面了,我是你们的朋友全栈君。
package hebingsrt;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Srt {
public static void main(String[] args) throws Exception {
String path1 = “C:\\Users\\Administrator\\Desktop\\in”;
String path2 = “C:\\Users\\Administrator\\Desktop\\out”;
String name = “basename”;
for (int i = 3; i
File src1 = new File(new File(path1), name + i + “.srt”);
File src2 = new File(new File(path1), name + i + “_2.srt”);
File src3 = new File(new File(path2), name + i + “.srt”);
InputStreamReader isr1 = new InputStreamReader(new FileInputStream(
src1), “UTF-8”);
InputStreamReader isr2 = new InputStreamReader(new FileInputStream(
src2), “UTF-8”);
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream(src3), “UTF-8”);
BufferedReader br1 = new BufferedReader(isr1);
BufferedReader br2 = new BufferedReader(isr2);
BufferedWriter bw = new BufferedWriter(osw);
while (true) {
int c = 0;
String temp1 = null;
String temp2 = null;
for (int j = 0; j
temp1 = br1.readLine();
if (temp1 != null)
bw.write(temp1);
temp2 = br2.readLine();
bw.newLine();
}
if (temp2 == null)
break;
bw.write(temp2);
br1.readLine();
bw.newLine();
bw.newLine();
temp2 = br2.readLine();
}
bw.flush();
}
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/157576.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...