校正srt字幕文件的时间[java源码]

<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>
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 ... {

staticintdm=1;
staticintds=20;

publicstaticvoidmain(String[]args)...{

Filef
=newFile("E:\1.txt");
FileReaderfileReader
=null;
BufferedReaderreader
=null;

Filefo
=newFile("E:\2.txt");

try...{

BufferedWriteroutput
=newBufferedWriter(newFileWriter(fo));

fileReader
=newFileReader(f.getAbsolutePath());

reader
=newBufferedReader(fileReader);

Stringline
="";
Stringtemp
=null;
intpos=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(FileNotFoundExceptione)...{
System.out.println(e.getMessage());
}
catch(IOExceptione)...{
System.out.println(e.getMessage());
}
catch(Exceptione)...{
System.out.println(e.getMessage());
}


try...{
if(reader!=null)...{
reader.close();
reader
=null;
}

}
catch(Exceptione)...{
System.out.println(e.getMessage());
}


}


privatestaticStringconvert(Stringline)...{
String[]tmp
=line.split("-->");
Stringt0
=conv(tmp[0]);
Stringt1
=conv(tmp[1]);
returnt0+"-->"+t1;
}


privatestaticStringconv(Stringstring)...{
String[]tmp
=string.split(",");
Stringtimes
=tmp[0];
Stringms
=tmp[1];
String[]tm
=times.split(":");
intp0=0;
intp1=0;

ints=Integer.parseInt(tm[2])+ds;
if(s>59)...{
s
-=60;
p0
++;
}


intm=Integer.parseInt(tm[1])+dm+p0;
if(m>59)...{
m
-=60;
p1
++;
}


inth=Integer.parseInt(tm[0])+p1;

returnpid(h)+":"+pid(m)+":"+pid(s)+","+ms;
}


privatestaticStringpid(inth)...{

return(h10)?"0"+h:""+h;
}


}



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1694795


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值