校正srt字幕文件的时间[java源码]
来源:互联网 发布:信贷资源配置需要优化 编辑:程序博客网 时间:2024/06/14 22:59
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class test ...{
static int dm = 1;
static int ds = 20;
public static void main(String[] args) ...{
File f = new File("E:/1.txt");
FileReader fileReader = null;
BufferedReader reader = null;
File fo = new File("E:/2.txt");
try ...{
BufferedWriter output = new BufferedWriter(new FileWriter(fo));
fileReader = new FileReader(f.getAbsolutePath());
reader = new BufferedReader(fileReader);
String line = "";
String temp = null;
int pos = 0;
while (line != null) ...{
pos++;
line = reader.readLine();
if (pos == 1) ...{
System.out.println(line);
}
if (pos == 2) ...{
temp = convert(line);
//System.out.println(temp);
} else ...{
temp = line;
}
if (temp == null) ...{
//System.out.println("NULL: " + line);
temp = "";
}
output.write(temp);
output.newLine();
output.flush();
if (line != null && line.equals("")) ...{
pos = 0;
}
}
} catch (FileNotFoundException e) ...{
System.out.println(e.getMessage());
} catch (IOException e) ...{
System.out.println(e.getMessage());
} catch (Exception e) ...{
System.out.println(e.getMessage());
}
try ...{
if (reader != null) ...{
reader.close();
reader = null;
}
} catch (Exception e) ...{
System.out.println(e.getMessage());
}
}
private static String convert(String line) ...{
String[] tmp = line.split(" --> ");
String t0 = conv(tmp[0]);
String t1 = conv(tmp[1]);
return t0 + " --> " + t1;
}
private static String conv(String string) ...{
String[] tmp = string.split(",");
String times = tmp[0];
String ms = tmp[1];
String[] tm = times.split(":");
int p0 = 0;
int p1 = 0;
int s = Integer.parseInt(tm[2]) + ds;
if (s > 59) ...{
s -= 60;
p0++;
}
int m = Integer.parseInt(tm[1]) + dm + p0;
if (m > 59) ...{
m -= 60;
p1++;
}
int h = Integer.parseInt(tm[0]) + p1;
return pid(h) + ":" + pid(m) + ":" + pid(s) + "," + ms;
}
private static String pid(int h) ...{
return (h < 10) ? "0" + h : "" + h;
}
}
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class test ...{
static int dm = 1;
static int ds = 20;
public static void main(String[] args) ...{
File f = new File("E:/1.txt");
FileReader fileReader = null;
BufferedReader reader = null;
File fo = new File("E:/2.txt");
try ...{
BufferedWriter output = new BufferedWriter(new FileWriter(fo));
fileReader = new FileReader(f.getAbsolutePath());
reader = new BufferedReader(fileReader);
String line = "";
String temp = null;
int pos = 0;
while (line != null) ...{
pos++;
line = reader.readLine();
if (pos == 1) ...{
System.out.println(line);
}
if (pos == 2) ...{
temp = convert(line);
//System.out.println(temp);
} else ...{
temp = line;
}
if (temp == null) ...{
//System.out.println("NULL: " + line);
temp = "";
}
output.write(temp);
output.newLine();
output.flush();
if (line != null && line.equals("")) ...{
pos = 0;
}
}
} catch (FileNotFoundException e) ...{
System.out.println(e.getMessage());
} catch (IOException e) ...{
System.out.println(e.getMessage());
} catch (Exception e) ...{
System.out.println(e.getMessage());
}
try ...{
if (reader != null) ...{
reader.close();
reader = null;
}
} catch (Exception e) ...{
System.out.println(e.getMessage());
}
}
private static String convert(String line) ...{
String[] tmp = line.split(" --> ");
String t0 = conv(tmp[0]);
String t1 = conv(tmp[1]);
return t0 + " --> " + t1;
}
private static String conv(String string) ...{
String[] tmp = string.split(",");
String times = tmp[0];
String ms = tmp[1];
String[] tm = times.split(":");
int p0 = 0;
int p1 = 0;
int s = Integer.parseInt(tm[2]) + ds;
if (s > 59) ...{
s -= 60;
p0++;
}
int m = Integer.parseInt(tm[1]) + dm + p0;
if (m > 59) ...{
m -= 60;
p1++;
}
int h = Integer.parseInt(tm[0]) + p1;
return pid(h) + ":" + pid(m) + ":" + pid(s) + "," + ms;
}
private static String pid(int h) ...{
return (h < 10) ? "0" + h : "" + h;
}
}
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- 校正srt字幕文件的时间[java源码]
- javascript实现多表头分类交叉报表:html表格
- jsf自定义组件-jafyear选择年份
- 今天的成果(excel报表):200多倍的生成效率
- jsf自定义toolbar组件
- 图片滤镜代码大全
- 校正srt字幕文件的时间[java源码]
- com.qsoft.commons.beanutils源代码(.net版本的org.apache.commons.beanutils)
- java中使用线程实现Timer(定时器)原理和源码
- java中数组的讨论:是不是类?
- BigInteger大整数类——实例和源码(相当经典)
- 通用线程:POSIX 线程详解,第 3 部分 使用条件变量提高效率
- .net实现3D饼图(test源码1)
- .net实现3D饼图
- [asp,jsp,asp.net]文件上传技术浅议~~